mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-04-07 14:28:52 +00:00
refactor(preferences): conditionally activate the Sieve script
All the user defaults are now editable through the Preferences module, even if an external Sieve script is enabled. However, the user can disable the external Sieve script and force the activation of the "sogo" Sieve script.
This commit is contained in:
@@ -25,18 +25,23 @@
|
||||
#import <NGObjWeb/WOContext+SoObjects.h>
|
||||
|
||||
#import <NGExtensions/NSObject+Logs.h>
|
||||
#import <NGImap4/NGSieveClient.h>
|
||||
|
||||
#import <SOPE/NGCards/iCalRecurrenceRule.h>
|
||||
|
||||
#import <SOGo/NSObject+Utilities.h>
|
||||
#import <SOGo/NSString+Utilities.h>
|
||||
#import <SOGo/SOGoDomainDefaults.h>
|
||||
#import <SOGo/SOGoSieveManager.h>
|
||||
#import <SOGo/SOGoUser.h>
|
||||
#import <SOGo/SOGoUserDefaults.h>
|
||||
#import <SOGo/SOGoUserFolder.h>
|
||||
#import <SOGo/SOGoUserSettings.h>
|
||||
#import <SOGo/SOGoUserProfile.h>
|
||||
#import <SOGo/WOResourceManager+SOGo.h>
|
||||
#import <SOGoUI/UIxComponent.h>
|
||||
#import <Mailer/SOGoMailAccount.h>
|
||||
#import <Mailer/SOGoMailAccounts.h>
|
||||
#import <Mailer/SOGoMailLabel.h>
|
||||
|
||||
#import "UIxJSONPreferences.h"
|
||||
@@ -71,6 +76,27 @@ static SoProduct *preferencesProduct = nil;
|
||||
return labelsDictionary;
|
||||
}
|
||||
|
||||
//
|
||||
// Used internally
|
||||
//
|
||||
- (BOOL) _hasActiveExternalSieveScripts
|
||||
{
|
||||
NGSieveClient *client;
|
||||
SOGoMailAccount *account;
|
||||
SOGoMailAccounts *folder;
|
||||
SOGoSieveManager *manager;
|
||||
|
||||
folder = [[[context activeUser] homeFolderInContext: context] mailAccountsFolder: @"Mail" inContext: context];
|
||||
account = [folder lookupName: @"0" inContext: context acquire: NO];
|
||||
manager = [SOGoSieveManager sieveManagerForUser: [context activeUser]];
|
||||
client = [manager clientForAccount: account];
|
||||
|
||||
if (client)
|
||||
return [manager hasActiveExternalSieveScripts: client];
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (WOResponse *) jsonDefaultsAction
|
||||
{
|
||||
return [self responseWithStatus: 200
|
||||
@@ -401,6 +427,9 @@ static SoProduct *preferencesProduct = nil;
|
||||
[values setObject: vacation forKey: @"Vacation"];
|
||||
}
|
||||
|
||||
// Detect if an external Sieve script is active
|
||||
[values setObject: [NSNumber numberWithBool: [self _hasActiveExternalSieveScripts]] forKey: @"hasActiveExternalSieveScripts"];
|
||||
|
||||
return [values jsonRepresentation];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user