Monotone-Parent: c4e25d84f9042e9b35f379e1d77a96da56e08bc0
Monotone-Revision: 5a4410525cba5a447107a195ccd7f2c23ac5f327 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-08-15T20:17:16 Monotone-Branch: ca.inverse.sogomaint-2.0.2
parent
b952f2fbb3
commit
872109dc42
|
@ -1,5 +1,12 @@
|
|||
2007-08-15 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* SoObjects/Mailer/SOGoMailAccounts.m ([-fetchAllIdentities]):
|
||||
removed method.
|
||||
([-fetchIdentitiesWithEmitterPermissions]): removed method.
|
||||
([SOGoMailAccounts -toManyRelationshipKeys]): rewrote method to
|
||||
return the name of the mail accounts now available with the
|
||||
-[SOGoUser mailAccounts] method.
|
||||
|
||||
* SoObjects/Mailer/SOGoUser+Mail.[hm]: removed useless class
|
||||
extension module.
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#ifndef __Mailer_SOGoMailAccounts_H__
|
||||
#define __Mailer_SOGoMailAccounts_H__
|
||||
|
||||
#include <SOGo/SOGoObject.h>
|
||||
#import <SOGo/SOGoObject.h>
|
||||
|
||||
/*
|
||||
SOGoMailAccounts
|
||||
|
@ -40,11 +40,6 @@
|
|||
@class NSArray;
|
||||
|
||||
@interface SOGoMailAccounts : SOGoObject
|
||||
{
|
||||
}
|
||||
|
||||
- (NSArray *)fetchAllIdentities;
|
||||
- (NSArray *)fetchIdentitiesWithEmitterPermissions;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -26,7 +26,8 @@
|
|||
#import <NGExtensions/NSNull+misc.h>
|
||||
#import <NGExtensions/NSObject+Logs.h>
|
||||
|
||||
#import "SOGoUser+Mail.h"
|
||||
#import "../SOGo/NSArray+Utilities.h"
|
||||
#import "../SOGo/SOGoUser.h"
|
||||
|
||||
#import "SOGoMailAccounts.h"
|
||||
|
||||
|
@ -38,72 +39,28 @@ static NSString *AgenorShareLoginMarker = @".-.";
|
|||
|
||||
- (BOOL) isInHomeFolderBranchOfLoggedInAccount: (NSString *) userLogin
|
||||
{
|
||||
return [[[self container] nameInContainer] isEqualToString: userLogin];
|
||||
return [[container nameInContainer] isEqualToString: userLogin];
|
||||
}
|
||||
|
||||
- (NSArray *)toManyRelationshipKeys {
|
||||
SOGoUser *user;
|
||||
id account;
|
||||
// NSArray *shares;
|
||||
NSString *userLogin;
|
||||
|
||||
/*
|
||||
Note: this is not strictly correct. The accounts being retrieved should be
|
||||
the accounts based on the container object of this folder. Given
|
||||
sufficient rights (eg delegation rights!), this would allow you to
|
||||
browse the hierarchies of other users.
|
||||
|
||||
But then, the home-folder would need to know about mail
|
||||
functionality which isn't perfect either.
|
||||
=> TODO
|
||||
*/
|
||||
user = [context activeUser];
|
||||
userLogin = [user login];
|
||||
|
||||
/* for now: return nothing if the home-folder does not belong to the login */
|
||||
if (![self isInHomeFolderBranchOfLoggedInAccount: userLogin]) {
|
||||
[self warnWithFormat:@"User %@ tried to access mail hierarchy of %@",
|
||||
[user login], [[self container] nameInContainer]];
|
||||
return nil;
|
||||
}
|
||||
|
||||
account = [user primaryIMAP4AccountString];
|
||||
if ([account isNotNull]) account = [NSArray arrayWithObject:account];
|
||||
|
||||
return account;
|
||||
// shares = [user valueForKey:@"additionalIMAP4AccountStrings"]
|
||||
// return ([shares count] == 0)
|
||||
// ? account
|
||||
// : [account arrayByAddingObjectsFromArray:shares];
|
||||
}
|
||||
|
||||
- (NSArray *) fetchIdentitiesWithOnlyEmitterAccess: (BOOL) _flag
|
||||
- (NSArray *) toManyRelationshipKeys
|
||||
{
|
||||
NSString *accountString;
|
||||
NSArray *accounts;
|
||||
|
||||
accountString = [[context activeUser] primaryIMAP4AccountString];
|
||||
accounts = [[context activeUser] mailAccounts];
|
||||
|
||||
return [NSArray arrayWithObject: accountString];
|
||||
}
|
||||
|
||||
- (NSArray *)fetchAllIdentities {
|
||||
return [self fetchIdentitiesWithOnlyEmitterAccess:NO];
|
||||
}
|
||||
|
||||
- (NSArray *)fetchIdentitiesWithEmitterPermissions {
|
||||
return [self fetchIdentitiesWithOnlyEmitterAccess:YES];
|
||||
return [accounts objectsForKey: @"name"];
|
||||
}
|
||||
|
||||
/* name lookup */
|
||||
|
||||
- (BOOL)isValidMailAccountName:(NSString *)_key {
|
||||
if ([_key length] == 0)
|
||||
return NO;
|
||||
|
||||
return YES;
|
||||
- (BOOL) isValidMailAccountName: (NSString *) _key
|
||||
{
|
||||
return ([_key length] > 0);
|
||||
}
|
||||
|
||||
- (id)mailAccountWithName:(NSString *)_key inContext:(id)_ctx {
|
||||
- (id) mailAccountWithName: (NSString *) _key
|
||||
inContext: (id) _ctx
|
||||
{
|
||||
static Class ctClass = Nil;
|
||||
id ct;
|
||||
|
||||
|
@ -118,22 +75,22 @@ static NSString *AgenorShareLoginMarker = @".-.";
|
|||
return [ct autorelease];
|
||||
}
|
||||
|
||||
- (id)sharedMailAccountWithName:(NSString *)_key inContext:(id)_ctx {
|
||||
- (id) sharedMailAccountWithName: (NSString *) _key
|
||||
inContext: (id) _ctx
|
||||
{
|
||||
static Class ctClass = Nil;
|
||||
id ct;
|
||||
|
||||
|
||||
if (ctClass == Nil)
|
||||
ctClass = NSClassFromString (@"SOGoSharedMailAccount");
|
||||
if (ctClass == Nil)
|
||||
ctClass = NSClassFromString(@"SOGoSharedMailAccount");
|
||||
if (ctClass == Nil) {
|
||||
[self errorWithFormat:@"missing SOGoSharedMailAccount class!"];
|
||||
return nil;
|
||||
}
|
||||
|
||||
ct = [[ctClass alloc] initWithName:_key inContainer:self];
|
||||
return [ct autorelease];
|
||||
return [ctClass objectWithName: _key inContainer: self];
|
||||
}
|
||||
|
||||
- (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag
|
||||
- (id) lookupName: (NSString *) _key
|
||||
inContext: (id) _ctx
|
||||
acquire: (BOOL) _flag
|
||||
{
|
||||
id obj;
|
||||
NSString *userLogin;
|
||||
|
@ -145,8 +102,8 @@ static NSString *AgenorShareLoginMarker = @".-.";
|
|||
return obj;
|
||||
|
||||
if (![self isInHomeFolderBranchOfLoggedInAccount: userLogin]) {
|
||||
[self warnWithFormat:@"User %@ tried to access mail hierarchy of %@",
|
||||
userLogin, [[self container] nameInContainer]];
|
||||
[self warnWithFormat:@ "User %@ tried to access mail hierarchy of %@",
|
||||
userLogin, [container nameInContainer]];
|
||||
|
||||
return [NSException exceptionWithHTTPStatus:403 /* Forbidden */
|
||||
reason:@"Tried to access the mail of another user"];
|
||||
|
|
Loading…
Reference in New Issue