mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-10-11 23:07:12 +00:00
Monotone-Parent: c494ba259363880f5d46e8931a1708d1ba1aed45
Monotone-Revision: 5f57280bc0c8371b942a310b60e1dfa1a790fb84 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-09-30T18:05:14 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
1 parent
80df885644
commit
79fc9f4c26
30 files changed
+712
-10
No files matched your search
@@ -37,7 +37,8 @@ Mailer_OBJC_FILES += \
|
||||
\
|
||||
EOQualifier+MailDAV.m \
|
||||
NSData+Mail.m \
|
||||
NSString+Mail.m
|
||||
NSString+Mail.m \
|
||||
SOGoUser+Mailer.m
|
||||
|
||||
Mailer_RESOURCE_FILES += \
|
||||
Version \
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
*/
|
||||
|
||||
@class NSArray;
|
||||
@class NSMutableArray;
|
||||
@class NSString;
|
||||
|
||||
@class SOGoMailFolder;
|
||||
@@ -55,6 +56,7 @@ typedef enum {
|
||||
SOGoSentFolder *sentFolder;
|
||||
SOGoTrashFolder *trashFolder;
|
||||
SOGoIMAPAclStyle imapAclStyle;
|
||||
NSMutableArray *identities;
|
||||
}
|
||||
|
||||
- (SOGoIMAPAclStyle) imapAclStyle;
|
||||
@@ -89,6 +91,11 @@ typedef enum {
|
||||
- (NSArray *) otherUsersFolderNamespaces;
|
||||
- (NSArray *) sharedFolderNamespaces;
|
||||
|
||||
/* account delegation */
|
||||
- (NSArray *) delegates;
|
||||
- (void) addDelegates: (NSArray *) newDelegates;
|
||||
- (void) removeDelegates: (NSArray *) oldDelegates;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __Mailer_SOGoMailAccount_H__ */
|
||||
@@ -44,7 +44,6 @@
|
||||
#import <SOGo/SOGoDomainDefaults.h>
|
||||
#import <SOGo/SOGoUser.h>
|
||||
#import <SOGo/SOGoUserDefaults.h>
|
||||
#import <SOGo/SOGoUserSettings.h>
|
||||
|
||||
#import "SOGoDraftsFolder.h"
|
||||
#import "SOGoMailFolder.h"
|
||||
@@ -53,7 +52,7 @@
|
||||
#import "SOGoSentFolder.h"
|
||||
#import "SOGoSieveConverter.h"
|
||||
#import "SOGoTrashFolder.h"
|
||||
|
||||
#import "SOGoUser+Mailer.h"
|
||||
|
||||
#import "SOGoMailAccount.h"
|
||||
|
||||
@@ -71,6 +70,7 @@ static NSString *sieveScriptName = @"sogo";
|
||||
sentFolder = nil;
|
||||
trashFolder = nil;
|
||||
imapAclStyle = undefined;
|
||||
identities = nil;
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -82,6 +82,7 @@ static NSString *sieveScriptName = @"sogo";
|
||||
[draftsFolder release];
|
||||
[sentFolder release];
|
||||
[trashFolder release];
|
||||
[identities release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@@ -482,17 +483,47 @@ static NSString *sieveScriptName = @"sogo";
|
||||
return mailAccount;
|
||||
}
|
||||
|
||||
- (void) _appendDelegatorIdentities
|
||||
{
|
||||
NSArray *delegators;
|
||||
SOGoUser *delegatorUser;
|
||||
NSDictionary *delegatorAccount;
|
||||
NSInteger count, max;
|
||||
|
||||
delegators = [[SOGoUser userWithLogin: owner] mailDelegators];
|
||||
max = [delegators count];
|
||||
for (count = 0; count < max; count++)
|
||||
{
|
||||
delegatorUser = [SOGoUser
|
||||
userWithLogin: [delegators objectAtIndex: count]];
|
||||
if (delegatorUser)
|
||||
{
|
||||
delegatorAccount = [[delegatorUser mailAccounts]
|
||||
objectAtIndex: 0];
|
||||
[identities addObjectsFromArray:
|
||||
[delegatorAccount objectForKey: @"identities"]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (NSArray *) identities
|
||||
{
|
||||
return [[self _mailAccount] objectForKey: @"identities"];
|
||||
if (!identities)
|
||||
{
|
||||
identities = [[[self _mailAccount] objectForKey: @"identities"]
|
||||
mutableCopy];
|
||||
if ([nameInContainer isEqualToString: @"0"])
|
||||
[self _appendDelegatorIdentities];
|
||||
}
|
||||
|
||||
return identities;
|
||||
}
|
||||
|
||||
- (NSString *) signature
|
||||
{
|
||||
NSArray *identities;
|
||||
NSString *signature;
|
||||
|
||||
identities = [self identities];
|
||||
[self identities];
|
||||
if ([identities count] > 0)
|
||||
signature = [[identities objectAtIndex: 0] objectForKey: @"signature"];
|
||||
else
|
||||
@@ -766,6 +797,93 @@ static NSString *sieveScriptName = @"sogo";
|
||||
return trashFolder;
|
||||
}
|
||||
|
||||
/* account delegation */
|
||||
- (NSArray *) delegates
|
||||
{
|
||||
NSDictionary *mailSettings;
|
||||
SOGoUser *ownerUser;
|
||||
NSArray *delegates;
|
||||
|
||||
if ([nameInContainer isEqualToString: @"0"])
|
||||
{
|
||||
ownerUser = [SOGoUser userWithLogin: [self ownerInContext: context]];
|
||||
mailSettings = [[ownerUser userSettings] objectForKey: @"Mail"];
|
||||
delegates = [mailSettings objectForKey: @"DelegateTo"];
|
||||
if (!delegates)
|
||||
delegates = [NSArray array];
|
||||
}
|
||||
else
|
||||
delegates = nil;
|
||||
|
||||
return delegates;
|
||||
}
|
||||
|
||||
- (void) _setDelegates: (NSArray *) newDelegates
|
||||
{
|
||||
SOGoUser *ownerUser;
|
||||
SOGoUserSettings *settings;
|
||||
|
||||
ownerUser = [SOGoUser userWithLogin: [self ownerInContext: context]];
|
||||
settings = [ownerUser userSettings];
|
||||
[[settings objectForKey: @"Mail"] setObject: newDelegates
|
||||
forKey: @"DelegateTo"];
|
||||
[settings synchronize];
|
||||
}
|
||||
|
||||
- (void) addDelegates: (NSArray *) newDelegates
|
||||
{
|
||||
NSMutableArray *delegates;
|
||||
NSInteger count, max;
|
||||
NSString *currentDelegate;
|
||||
SOGoUser *delegateUser;
|
||||
|
||||
if ([nameInContainer isEqualToString: @"0"])
|
||||
{
|
||||
delegates = [[self delegates] mutableCopy];
|
||||
[delegates autorelease];
|
||||
max = [newDelegates count];
|
||||
for (count = 0; count < max; count++)
|
||||
{
|
||||
currentDelegate = [newDelegates objectAtIndex: 0];
|
||||
delegateUser = [SOGoUser userWithLogin: currentDelegate];
|
||||
if (delegateUser)
|
||||
{
|
||||
[delegates addObjectUniquely: currentDelegate];
|
||||
[delegateUser addMailDelegator: owner];
|
||||
}
|
||||
}
|
||||
|
||||
[self _setDelegates: delegates];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) removeDelegates: (NSArray *) oldDelegates
|
||||
{
|
||||
NSMutableArray *delegates;
|
||||
NSInteger count, max;
|
||||
NSString *currentDelegate;
|
||||
SOGoUser *delegateUser;
|
||||
|
||||
if ([nameInContainer isEqualToString: @"0"])
|
||||
{
|
||||
delegates = [[self delegates] mutableCopy];
|
||||
[delegates autorelease];
|
||||
max = [oldDelegates count];
|
||||
for (count = 0; count < max; count++)
|
||||
{
|
||||
currentDelegate = [oldDelegates objectAtIndex: 0];
|
||||
delegateUser = [SOGoUser userWithLogin: currentDelegate];
|
||||
if (delegateUser)
|
||||
{
|
||||
[delegates removeObject: currentDelegate];
|
||||
[delegateUser removeMailDelegator: owner];
|
||||
}
|
||||
}
|
||||
|
||||
[self _setDelegates: delegates];
|
||||
}
|
||||
}
|
||||
|
||||
/* WebDAV */
|
||||
|
||||
- (NSString *) davContentType
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/* SOGoUser+Mailer.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2010 Inverse inc.
|
||||
*
|
||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef SOGOUSER_MAILER_H
|
||||
#define SOGOUSER_MAILER_H
|
||||
|
||||
#import <SOGo/SOGoUser.h>
|
||||
|
||||
@interface SOGoUser (SOGoMailExtensions)
|
||||
|
||||
- (NSArray *) mailDelegators;
|
||||
- (void) addMailDelegator: (NSString *) newDelegator;
|
||||
- (void) removeMailDelegator: (NSString *) oldDelegator;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* SOGOUSER_MAILER_H */
|
||||
@@ -0,0 +1,77 @@
|
||||
/* SOGoUser+Mailer.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2010 Inverse inc.
|
||||
*
|
||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
#import <SOGo/NSArray+Utilities.h>
|
||||
#import <SOGo/SOGoUserSettings.h>
|
||||
|
||||
#import "SOGoUser+Mailer.h"
|
||||
|
||||
@implementation SOGoUser (SOGoMailExtensions)
|
||||
|
||||
- (NSArray *) mailDelegators
|
||||
{
|
||||
NSDictionary *mailSettings;
|
||||
NSArray *mailDelegators;
|
||||
|
||||
mailSettings = [[self userSettings] objectForKey: @"Mail"];
|
||||
mailDelegators = [mailSettings objectForKey: @"DelegateFrom"];
|
||||
if (!mailDelegators)
|
||||
mailDelegators = [NSArray array];
|
||||
|
||||
return mailDelegators;
|
||||
}
|
||||
|
||||
- (void) _setMailDelegators: (NSArray *) newDelegators
|
||||
{
|
||||
SOGoUserSettings *settings;
|
||||
|
||||
settings = [self userSettings];
|
||||
[[settings objectForKey: @"Mail"] setObject: newDelegators
|
||||
forKey: @"DelegateFrom"];
|
||||
[settings synchronize];
|
||||
}
|
||||
|
||||
- (void) addMailDelegator: (NSString *) newDelegator
|
||||
{
|
||||
NSMutableArray *delegators;
|
||||
|
||||
delegators = [[self mailDelegators] mutableCopy];
|
||||
[delegators autorelease];
|
||||
[delegators addObjectUniquely: newDelegator];
|
||||
|
||||
[self _setMailDelegators: delegators];
|
||||
}
|
||||
|
||||
- (void) removeMailDelegator: (NSString *) oldDelegator
|
||||
{
|
||||
NSMutableArray *delegators;
|
||||
|
||||
delegators = [[self mailDelegators] mutableCopy];
|
||||
[delegators autorelease];
|
||||
[delegators removeObject: oldDelegator];
|
||||
|
||||
[self _setMailDelegators: delegators];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user