Monotone-Parent: 6364fd26aed4532b46cd1c779ef5e9f5f6c0971c

Monotone-Revision: fd35d485688e2370ae5250cfa15931e93abfd567

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2010-03-02T19:57:30
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2010-03-02 19:57:30 +00:00
parent e2f1faa697
commit f81f48cb90
28 changed files with 2207 additions and 62 deletions
+2
View File
@@ -13,6 +13,8 @@ PreferencesUI_OBJC_FILES = \
\
UIxJSONPreferences.m \
UIxPreferences.m \
UIxFilterEditor.m \
\
UIxAdditionalPreferences.m
PreferencesUI_RESOURCE_FILES += \
+8
View File
@@ -0,0 +1,8 @@
# compile settings
SUBMINOR_VERSION:=1
ADDITIONAL_CPPFLAGS += \
-DSOGO_MAJOR_VERSION=$(MAJOR_VERSION) \
-DSOGO_MINOR_VERSION=$(MINOR_VERSION) \
-DSOGO_SUBMINOR_VERSION=$(SUBMINOR_VERSION)
+104
View File
@@ -0,0 +1,104 @@
/* UIxFilterEditor.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/NSCharacterSet.h>
#import <NGObjWeb/WORequest.h>
#import <NGObjWeb/WOResponse.h>
#import <SOGo/NSString+Utilities.h>
#import <SOGo/SOGoUser.h>
#import <SOGoUI/UIxComponent.h>
@interface UIxFilterEditor : UIxComponent
{
NSString *filterId;
}
@end
@implementation UIxFilterEditor
/* convert and save */
- (BOOL) _validateFilterId
{
NSCharacterSet *digits;
BOOL rc;
digits = [NSCharacterSet decimalDigitCharacterSet];
rc = ([filterId isEqualToString: @"new"]
|| [[filterId stringByTrimmingCharactersInSet: digits] length] == 0);
return rc;
}
- (id <WOActionResults>) defaultAction
{
id <WOActionResults> result;
WORequest *request;
request = [context request];
ASSIGN (filterId, [request formValueForKey: @"filter"]);
if (filterId)
{
if ([self _validateFilterId])
result = self;
else
result = [self responseWithStatus: 403
andString: @"Bad value for 'filter'"];
}
else
result = [self responseWithStatus: 403
andString: @"Missing 'filter' parameter"];
return result;
}
- (NSString *) filterId
{
return filterId;
}
- (NSString *) firstMailAccount
{
NSArray *accounts;
NSDictionary *account;
NSString *login, *accountName;
SOGoUser *ownerUser;
login = [[self clientObject] nameInContainer];
ownerUser = [SOGoUser userWithLogin: login];
accounts = [ownerUser mailAccounts];
if ([accounts count] > 0)
{
account = [accounts objectAtIndex: 0];
accountName = [[account objectForKey: @"name"] asCSSIdentifier];
}
else
accountName = @"";
return accountName;
}
@end
+1
View File
@@ -42,6 +42,7 @@
SOGoUserDefaults *userDefaults;
NSCalendarDate *today;
NSArray *daysOfWeek, *daysBetweenResponsesList;
NSArray *sieveFilters;
NSMutableDictionary *vacationOptions, *forwardOptions;
BOOL hasChanged, composeMessageTypeHasChanged;
}
+56 -12
View File
@@ -21,10 +21,11 @@
*/
#import <Foundation/NSCalendarDate.h>
#import <Foundation/NSPropertyList.h>
#import <Foundation/NSScanner.h>
#import <Foundation/NSString.h>
#import <Foundation/NSTimeZone.h>
#import <Foundation/NSUserDefaults.h> /* for locale strings */
#import <Foundation/NSPropertyList.h>
#import <Foundation/NSValue.h>
#import <NGObjWeb/WOContext.h>
@@ -35,6 +36,7 @@
#import <SOGo/NSArray+Utilities.h>
#import <SOGo/NSDictionary+BSJSONAdditions.h>
#import <SOGo/NSDictionary+Utilities.h>
#import <SOGo/NSScanner+BSJSONAdditions.h>
#import <SOGo/NSString+Utilities.h>
#import <SOGo/SOGoUser.h>
#import <SOGo/SOGoUserDefaults.h>
@@ -83,6 +85,13 @@
composeMessageTypeHasChanged = NO;
dd = [user domainDefaults];
if ([dd sieveScriptsEnabled])
{
sieveFilters = [[userDefaults sieveFilters] copy];
if (!sieveFilters)
sieveFilters = [NSArray new];
}
if ([dd vacationEnabled])
{
vacationOptions = [[userDefaults vacationOptions] mutableCopy];
@@ -107,6 +116,7 @@
[item release];
[user release];
[userDefaults release];
[sieveFilters release];
[vacationOptions release];
[calendarCategories release];
[calendarCategoriesColors release];
@@ -661,11 +671,54 @@
/* mail autoreply (vacation) */
- (BOOL) isSieveScriptsEnabled
{
return [[user domainDefaults] sieveScriptsEnabled];
}
- (NSString *) sieveCapabilities
{
#warning this should be deduced from the server
static NSArray *capabilities = nil;
if (!capabilities)
{
capabilities = [NSArray arrayWithObjects: @"fileinto", @"reject",
@"envelope", @"vacation", @"imapflags",
@"notify", @"subaddress", @"relational",
@"comparator-i;ascii-numeric", @"regex", nil];
[capabilities retain];
}
return [[NSDictionary dictionary]
jsonStringForArray: capabilities
withIndentLevel: 0];
}
- (BOOL) isVacationEnabled
{
return [[user domainDefaults] vacationEnabled];
}
- (void) setSieveFiltersValue: (NSString *) newValue
{
NSScanner *jsonScanner;
if ([newValue hasPrefix: @"["])
{
jsonScanner = [NSScanner scannerWithString: newValue];
[jsonScanner scanJSONArray: &sieveFilters];
[sieveFilters retain];
}
}
- (NSString *) sieveFiltersValue
{
return [[NSDictionary dictionary]
jsonStringForArray: sieveFilters
withIndentLevel: 0];
}
- (void) setEnableVacation: (BOOL) enableVacation
{
[vacationOptions setObject: [NSNumber numberWithBool: enableVacation]
@@ -884,6 +937,8 @@
id folder;
dd = [[context activeUser] domainDefaults];
if ([dd sieveScriptsEnabled])
[userDefaults setSieveFilters: sieveFilters];
if ([dd vacationEnabled])
[userDefaults setVacationOptions: vacationOptions];
if ([dd forwardEnabled])
@@ -897,7 +952,6 @@
account = [folder lookupName: [[mailAccounts objectForKey: @"name"] asCSSIdentifier]
inContext: context
acquire: NO];
[account updateFilters];
if (composeMessageTypeHasChanged)
@@ -947,16 +1001,6 @@
userCanChangePassword];
}
- (NSString *) nameLabel
{
return [self labelForKey: @"Name"];
}
- (NSString *) colorLabel
{
return [self labelForKey: @"Color"];
}
- (NSArray *) languageCategories
{
NSArray *categoryLabels;
+4
View File
@@ -19,6 +19,10 @@
protectedBy = "View";
pageName = "UIxPreferences";
};
editFilter = {
protectedBy = "View";
pageName = "UIxFilterEditor";
};
identities = {
protectedBy = "View";
pageName = "UIxIdentities";