Fix sogo-tool operations on Sieve script

Fixes #2617
This commit is contained in:
Francis Lachapelle committed 2014-03-03 22:07:24 -05:00
1 parent c6b227160c
commit 1aabcf04b5
8 files changed
+118 -32

No files matched your search

+24 -6
View File
@@ -36,13 +36,19 @@
#import <NGExtensions/NSNull+misc.h>
#import <NGObjWeb/WOContext+SoObjects.h>
#import <SOGo/NSString+Utilities.h>
#import "SOGo/SOGoCredentialsFile.h"
#import <SOGo/SOGoProductLoader.h>
#import <SOGo/SOGoSieveManager.h>
#import <SOGo/SOGoSystemDefaults.h>
#import <SOGo/SOGoUser.h>
#import <SOGo/SOGoUserDefaults.h>
#import <Mailer/SOGoMailAccounts.h>
#import <Mailer/SOGoMailAccount.h>
#import "SOGoTool.h"
@interface SOGoToolExpireAutoReply : SOGoTool
@@ -80,12 +86,10 @@
{
NSMutableDictionary *vacationOptions;
SOGoUserDefaults *userDefaults;
SOGoSieveManager *manager;
SOGoUser *user;
BOOL result;
user = [SOGoUser userWithLogin: theLogin];
manager = [SOGoSieveManager sieveManagerForUser: user];
userDefaults = [user userDefaults];
vacationOptions = [[userDefaults vacationOptions] mutableCopy];
[vacationOptions autorelease];
@@ -96,10 +100,24 @@
if (result)
{
result = [manager updateFiltersForLogin: theLogin
authname: theUsername
password: thePassword
account: nil];
SOGoUserFolder *home;
SOGoMailAccounts *folder;
SOGoMailAccount *account;
WOContext *localContext;
Class SOGoMailAccounts_class;
[[SOGoProductLoader productLoader] loadProducts: [NSArray arrayWithObject: @"Mailer.SOGo"]];
SOGoMailAccounts_class = NSClassFromString(@"SOGoMailAccounts");
localContext = [WOContext context];
[localContext setActiveUser: user];
home = [user homeFolderInContext: localContext];
folder = [SOGoMailAccounts_class objectWithName: @"Mail" inContainer: home];
account = [folder lookupName: @"0" inContext: localContext acquire: NO];
[account setContext: localContext];
result = [account updateFiltersWithUsername: theUsername andPassword: thePassword];
if (!result)
{
// Can't update Sieve script -- Reactivate auto-reply