2007-06-19 19:58:21 +02:00
|
|
|
/* UIxPreferences.m - this file is part of SOGo
|
|
|
|
*
|
2009-04-01 15:49:24 +02:00
|
|
|
* Copyright (C) 2007-2009 Inverse inc.
|
2007-06-19 19:58:21 +02:00
|
|
|
*
|
|
|
|
* 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/NSCalendarDate.h>
|
|
|
|
#import <Foundation/NSString.h>
|
|
|
|
#import <Foundation/NSTimeZone.h>
|
|
|
|
#import <Foundation/NSUserDefaults.h>
|
2009-07-16 17:57:31 +02:00
|
|
|
#import <Foundation/NSPropertyList.h>
|
2007-06-19 19:58:21 +02:00
|
|
|
|
|
|
|
#import <NGObjWeb/WOContext.h>
|
|
|
|
#import <NGObjWeb/WORequest.h>
|
|
|
|
|
2007-11-19 23:44:12 +01:00
|
|
|
#import <SoObjects/SOGo/NSArray+Utilities.h>
|
2007-11-06 18:13:15 +01:00
|
|
|
#import <SoObjects/SOGo/NSDictionary+Utilities.h>
|
2007-06-19 19:58:21 +02:00
|
|
|
#import <SoObjects/SOGo/SOGoUser.h>
|
2009-04-01 15:49:24 +02:00
|
|
|
#import "../../Main/SOGo.h"
|
2007-06-19 19:58:21 +02:00
|
|
|
|
|
|
|
#import "UIxPreferences.h"
|
|
|
|
|
|
|
|
#warning this class is not finished
|
|
|
|
/* remaining:
|
|
|
|
default event length
|
|
|
|
default snooze length
|
|
|
|
refresh calendar every X minutes
|
|
|
|
workweek = from -> to
|
|
|
|
identities */
|
|
|
|
|
2007-07-23 16:11:26 +02:00
|
|
|
static BOOL defaultsRead = NO;
|
2007-07-22 22:17:34 +02:00
|
|
|
static BOOL shouldDisplayPasswordChange = NO;
|
2008-08-21 04:36:04 +02:00
|
|
|
static BOOL shouldDisplayAdditionalPreferences = NO;
|
2009-05-20 01:31:51 +02:00
|
|
|
static BOOL defaultShowSubscribedFoldersOnly = NO;
|
2007-07-22 22:17:34 +02:00
|
|
|
|
2007-06-19 19:58:21 +02:00
|
|
|
@implementation UIxPreferences
|
|
|
|
|
2007-07-22 22:17:34 +02:00
|
|
|
+ (void) initialize
|
|
|
|
{
|
|
|
|
NSUserDefaults *ud;
|
|
|
|
|
2007-07-23 16:11:26 +02:00
|
|
|
if (!defaultsRead)
|
|
|
|
{
|
|
|
|
ud = [NSUserDefaults standardUserDefaults];
|
|
|
|
shouldDisplayPasswordChange
|
|
|
|
= [ud boolForKey: @"SOGoUIxUserCanChangePassword"];
|
2008-08-21 04:36:04 +02:00
|
|
|
shouldDisplayAdditionalPreferences
|
|
|
|
= [ud boolForKey: @"SOGoUIxAdditionalPreferences"];
|
2009-05-20 01:31:51 +02:00
|
|
|
defaultShowSubscribedFoldersOnly
|
|
|
|
= [ud boolForKey: @"SOGoMailShowSubscribedFoldersOnly"];
|
2007-07-23 16:11:26 +02:00
|
|
|
defaultsRead = YES;
|
|
|
|
}
|
2007-07-22 22:17:34 +02:00
|
|
|
}
|
|
|
|
|
2007-06-19 19:58:21 +02:00
|
|
|
- (id) init
|
|
|
|
{
|
2008-12-23 01:12:14 +01:00
|
|
|
//NSDictionary *locale;
|
|
|
|
NSString *language;
|
2007-06-19 19:58:21 +02:00
|
|
|
|
|
|
|
if ((self = [super init]))
|
|
|
|
{
|
2008-12-23 01:12:14 +01:00
|
|
|
language = [[context activeUser] language];
|
|
|
|
|
2007-06-19 19:58:21 +02:00
|
|
|
item = nil;
|
|
|
|
hours = nil;
|
|
|
|
ASSIGN (user, [context activeUser]);
|
|
|
|
ASSIGN (userDefaults, [user userDefaults]);
|
|
|
|
ASSIGN (today, [NSCalendarDate date]);
|
2008-12-23 01:12:14 +01:00
|
|
|
//locale = [context valueForKey: @"locale"];
|
|
|
|
ASSIGN (locale, [[WOApplication application] localeForLanguageNamed: language]);
|
2007-06-19 19:58:21 +02:00
|
|
|
ASSIGN (daysOfWeek,
|
|
|
|
[locale objectForKey: NSWeekDayNameArray]);
|
2008-07-25 20:44:31 +02:00
|
|
|
hasChanged = NO;
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
[today release];
|
|
|
|
[item release];
|
|
|
|
[user release];
|
|
|
|
[userDefaults release];
|
|
|
|
[hours release];
|
|
|
|
[daysOfWeek release];
|
2008-12-23 01:12:14 +01:00
|
|
|
[locale release];
|
2007-06-19 19:58:21 +02:00
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
2008-07-25 20:44:31 +02:00
|
|
|
- (void) setHasChanged: (BOOL) newHasChanged
|
|
|
|
{
|
|
|
|
hasChanged = newHasChanged;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) hasChanged
|
|
|
|
{
|
|
|
|
return hasChanged;
|
|
|
|
}
|
|
|
|
|
2007-06-19 19:58:21 +02:00
|
|
|
- (void) setItem: (NSString *) newItem
|
|
|
|
{
|
|
|
|
ASSIGN (item, newItem);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) item
|
|
|
|
{
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) inTheOffice
|
|
|
|
{
|
|
|
|
NSString *inTheOffice;
|
|
|
|
|
|
|
|
inTheOffice = [userDefaults objectForKey: @"InTheOffice"];
|
|
|
|
|
|
|
|
return ((!inTheOffice || [inTheOffice boolValue])
|
|
|
|
? @"YES" : @"NO");
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setInTheOffice: (NSString *) newValue
|
|
|
|
{
|
|
|
|
[userDefaults setObject: newValue forKey: @"InTheOffice"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setAutoReplyText: (NSString *) newAutoReplyText
|
|
|
|
{
|
|
|
|
[userDefaults setObject: newAutoReplyText forKey: @"AutoReplyText"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) autoReplyText
|
|
|
|
{
|
|
|
|
return [userDefaults objectForKey: @"AutoReplyText"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) timeZonesList
|
|
|
|
{
|
2007-09-15 00:01:02 +02:00
|
|
|
return [[NSTimeZone knownTimeZoneNames]
|
|
|
|
sortedArrayUsingSelector: @selector (localizedCaseInsensitiveCompare:)];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userTimeZone
|
|
|
|
{
|
|
|
|
return [[user timeZone] timeZoneName];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserTimeZone: (NSString *) newUserTimeZone
|
|
|
|
{
|
|
|
|
[userDefaults setObject: newUserTimeZone forKey: @"TimeZone"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) shortDateFormatsList
|
|
|
|
{
|
|
|
|
NSMutableArray *shortDateFormatsList = nil;
|
|
|
|
NSString *key, *currentFormat;
|
|
|
|
unsigned int nbr;
|
|
|
|
BOOL done;
|
|
|
|
|
|
|
|
shortDateFormatsList = [NSMutableArray array];
|
|
|
|
|
|
|
|
nbr = 0;
|
|
|
|
done = NO;
|
|
|
|
while (!done)
|
|
|
|
{
|
|
|
|
key = [NSString stringWithFormat: @"shortDateFmt_%d", nbr];
|
|
|
|
currentFormat = [self labelForKey: key];
|
|
|
|
if ([currentFormat length] > 0)
|
|
|
|
{
|
|
|
|
[shortDateFormatsList addObject: currentFormat];
|
|
|
|
nbr++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
done = YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
return shortDateFormatsList;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemShortDateFormatText
|
|
|
|
{
|
|
|
|
return [today descriptionWithCalendarFormat: item
|
2008-12-23 01:12:14 +01:00
|
|
|
locale: locale];
|
|
|
|
//locale: [context valueForKey: @"locale"]];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userShortDateFormat
|
|
|
|
{
|
|
|
|
return [userDefaults objectForKey: @"ShortDateFormat"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserShortDateFormat: (NSString *) newFormat
|
|
|
|
{
|
|
|
|
[userDefaults setObject: newFormat forKey: @"ShortDateFormat"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) longDateFormatsList
|
|
|
|
{
|
|
|
|
NSMutableArray *longDateFormatsList = nil;
|
|
|
|
NSString *key, *currentFormat;
|
|
|
|
unsigned int nbr;
|
|
|
|
BOOL done;
|
|
|
|
|
|
|
|
longDateFormatsList = [NSMutableArray array];
|
|
|
|
|
|
|
|
nbr = 0;
|
|
|
|
done = NO;
|
|
|
|
while (!done)
|
|
|
|
{
|
|
|
|
key = [NSString stringWithFormat: @"longDateFmt_%d", nbr];
|
|
|
|
currentFormat = [self labelForKey: key];
|
|
|
|
if ([currentFormat length] > 0)
|
|
|
|
{
|
|
|
|
[longDateFormatsList addObject: currentFormat];
|
|
|
|
nbr++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
done = YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
return longDateFormatsList;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemLongDateFormatText
|
|
|
|
{
|
|
|
|
return [today descriptionWithCalendarFormat: item
|
2008-12-23 01:12:14 +01:00
|
|
|
locale: locale];
|
|
|
|
//locale: [context valueForKey: @"locale"]];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userLongDateFormat
|
|
|
|
{
|
|
|
|
return [userDefaults objectForKey: @"LongDateFormat"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserLongDateFormat: (NSString *) newFormat
|
|
|
|
{
|
|
|
|
[userDefaults setObject: newFormat forKey: @"LongDateFormat"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) timeFormatsList
|
|
|
|
{
|
|
|
|
NSMutableArray *timeFormatsList = nil;
|
|
|
|
NSString *key, *currentFormat;
|
|
|
|
unsigned int nbr;
|
|
|
|
BOOL done;
|
|
|
|
|
|
|
|
timeFormatsList = [NSMutableArray array];
|
|
|
|
|
|
|
|
nbr = 0;
|
|
|
|
done = NO;
|
|
|
|
while (!done)
|
|
|
|
{
|
|
|
|
key = [NSString stringWithFormat: @"timeFmt_%d", nbr];
|
|
|
|
currentFormat = [self labelForKey: key];
|
|
|
|
if ([currentFormat length] > 0)
|
|
|
|
{
|
|
|
|
[timeFormatsList addObject: currentFormat];
|
|
|
|
nbr++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
done = YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
return timeFormatsList;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemTimeFormatText
|
|
|
|
{
|
|
|
|
return [today descriptionWithCalendarFormat: item
|
2008-12-23 01:12:14 +01:00
|
|
|
locale: locale];
|
|
|
|
//locale: [context valueForKey: @"locale"]];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userTimeFormat
|
|
|
|
{
|
|
|
|
return [userDefaults objectForKey: @"TimeFormat"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserTimeFormat: (NSString *) newFormat
|
|
|
|
{
|
|
|
|
[userDefaults setObject: newFormat forKey: @"TimeFormat"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) daysList
|
|
|
|
{
|
|
|
|
NSMutableArray *daysList;
|
|
|
|
unsigned int currentDay;
|
|
|
|
|
|
|
|
daysList = [NSMutableArray new];
|
|
|
|
[daysList autorelease];
|
|
|
|
for (currentDay = 0; currentDay < 7; currentDay++)
|
|
|
|
[daysList addObject: [NSString stringWithFormat: @"%d", currentDay]];
|
|
|
|
|
|
|
|
return daysList;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemWeekStartDay
|
|
|
|
{
|
|
|
|
return [daysOfWeek objectAtIndex: [item intValue]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userWeekStartDay
|
|
|
|
{
|
|
|
|
return [userDefaults objectForKey: @"WeekStartDay"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserWeekStartDay: (NSString *) newDay
|
|
|
|
{
|
|
|
|
[userDefaults setObject: newDay forKey: @"WeekStartDay"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) hoursList
|
|
|
|
{
|
|
|
|
unsigned int currentHour;
|
|
|
|
|
|
|
|
if (!hours)
|
|
|
|
{
|
|
|
|
hours = [[NSMutableArray alloc] initWithCapacity: 24];
|
|
|
|
for (currentHour = 0; currentHour < 24; currentHour++)
|
|
|
|
[hours addObject: [NSString stringWithFormat: @"%.2d:00",
|
|
|
|
currentHour]];
|
|
|
|
}
|
|
|
|
|
|
|
|
return hours;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userDayStartTime
|
|
|
|
{
|
|
|
|
NSString *time;
|
|
|
|
|
|
|
|
time = [userDefaults objectForKey: @"DayStartTime"];
|
|
|
|
if (!time)
|
|
|
|
time = @"08:00";
|
|
|
|
|
|
|
|
return time;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserDayStartTime: (NSString *) newTime
|
|
|
|
{
|
|
|
|
[userDefaults setObject: newTime forKey: @"DayStartTime"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userDayEndTime
|
|
|
|
{
|
|
|
|
NSString *time;
|
|
|
|
|
|
|
|
time = [userDefaults objectForKey: @"DayEndTime"];
|
|
|
|
if (!time)
|
|
|
|
time = @"18:00";
|
|
|
|
|
|
|
|
return time;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserDayEndTime: (NSString *) newTime
|
|
|
|
{
|
|
|
|
[userDefaults setObject: newTime forKey: @"DayEndTime"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) firstWeekList
|
|
|
|
{
|
2008-07-18 21:25:26 +02:00
|
|
|
return [NSArray arrayWithObjects:
|
|
|
|
SOGoWeekStartJanuary1,
|
2007-06-19 19:58:21 +02:00
|
|
|
SOGoWeekStartFirst4DayWeek,
|
2008-07-18 21:25:26 +02:00
|
|
|
SOGoWeekStartFirstFullWeek,
|
|
|
|
nil];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemFirstWeekText
|
|
|
|
{
|
|
|
|
return [self labelForKey: [NSString stringWithFormat: @"firstWeekOfYear_%@",
|
|
|
|
item]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userFirstWeek
|
|
|
|
{
|
|
|
|
return [userDefaults objectForKey: @"FirstWeek"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserFirstWeek: (NSString *) newFirstWeek
|
|
|
|
{
|
|
|
|
[userDefaults setObject: newFirstWeek forKey: @"FirstWeek"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) reminderEnabled
|
|
|
|
{
|
|
|
|
NSString *reminderEnabled;
|
|
|
|
|
|
|
|
reminderEnabled = [userDefaults objectForKey: @"ReminderEnabled"];
|
|
|
|
|
|
|
|
return ((!reminderEnabled || [reminderEnabled boolValue])
|
|
|
|
? @"YES" : @"NO");
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setReminderEnabled: (NSString *) newValue
|
|
|
|
{
|
|
|
|
[userDefaults setObject: newValue forKey: @"ReminderEnabled"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) remindWithASound
|
|
|
|
{
|
|
|
|
NSString *remindWithASound;
|
|
|
|
|
|
|
|
remindWithASound = [userDefaults objectForKey: @"RemindWithASound"];
|
|
|
|
|
|
|
|
return ((!remindWithASound || [remindWithASound boolValue])
|
|
|
|
? @"YES" : @"NO");
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setRemindWithASound: (NSString *) newValue
|
|
|
|
{
|
|
|
|
[userDefaults setObject: newValue forKey: @"RemindWithASound"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) reminderTimesList
|
|
|
|
{
|
|
|
|
return [NSArray arrayWithObjects: @"0000", @"0005", @"0010", @"0015",
|
|
|
|
@"0030", @"0100", @"0200", @"0400", @"0800", @"1200",
|
|
|
|
@"2400", @"4800", nil];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemReminderTimeText
|
|
|
|
{
|
|
|
|
return [self labelForKey:
|
|
|
|
[NSString stringWithFormat: @"reminderTime_%@", item]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userReminderTime
|
|
|
|
{
|
|
|
|
return [userDefaults objectForKey: @"ReminderTime"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setReminderTime: (NSString *) newTime
|
|
|
|
{
|
|
|
|
[userDefaults setObject: newTime forKey: @"ReminderTime"];
|
|
|
|
}
|
|
|
|
|
2007-08-22 17:18:01 +02:00
|
|
|
/* Mailer */
|
2009-05-15 22:26:25 +02:00
|
|
|
- (void) setShowSubscribedFoldersOnly: (BOOL) showSubscribedFoldersOnly
|
|
|
|
{
|
|
|
|
if (showSubscribedFoldersOnly)
|
|
|
|
[userDefaults setBool: YES forKey: @"showSubscribedFoldersOnly"];
|
|
|
|
else
|
2009-05-20 01:31:51 +02:00
|
|
|
[userDefaults setBool: NO forKey: @"showSubscribedFoldersOnly"];
|
2009-05-15 22:26:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) showSubscribedFoldersOnly
|
|
|
|
{
|
2009-05-20 01:31:51 +02:00
|
|
|
NSString *showSubscribedFoldersOnly;
|
|
|
|
BOOL r;
|
|
|
|
|
|
|
|
showSubscribedFoldersOnly = [userDefaults stringForKey: @"showSubscribedFoldersOnly"];
|
|
|
|
if (showSubscribedFoldersOnly)
|
|
|
|
r = [showSubscribedFoldersOnly boolValue];
|
|
|
|
else
|
|
|
|
r = defaultShowSubscribedFoldersOnly;
|
|
|
|
|
|
|
|
return r;
|
2009-05-15 22:26:25 +02:00
|
|
|
}
|
|
|
|
|
2007-10-26 17:35:51 +02:00
|
|
|
- (NSArray *) messageCheckList
|
|
|
|
{
|
|
|
|
return [NSArray arrayWithObjects: @"manually", @"every_minute",
|
|
|
|
@"every_2_minutes", @"every_5_minutes", @"every_10_minutes",
|
|
|
|
@"every_20_minutes", @"every_30_minutes", @"once_per_hour",
|
|
|
|
nil];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemMessageCheckText
|
|
|
|
{
|
|
|
|
return [self labelForKey:
|
|
|
|
[NSString stringWithFormat: @"messagecheck_%@", item]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userMessageCheck
|
|
|
|
{
|
2008-10-29 20:23:31 +01:00
|
|
|
return [userDefaults stringForKey: @"MessageCheck"];
|
2007-10-26 17:35:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserMessageCheck: (NSString *) newMessageCheck
|
|
|
|
{
|
|
|
|
[userDefaults setObject: newMessageCheck forKey: @"MessageCheck"];
|
|
|
|
}
|
|
|
|
|
2007-08-22 17:18:01 +02:00
|
|
|
- (NSArray *) messageForwardingList
|
|
|
|
{
|
|
|
|
return [NSArray arrayWithObjects: @"inline", @"attached", nil];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemMessageForwardingText
|
|
|
|
{
|
|
|
|
return [self labelForKey:
|
|
|
|
[NSString stringWithFormat: @"messageforward_%@", item]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userMessageForwarding
|
|
|
|
{
|
2008-10-29 20:23:31 +01:00
|
|
|
return [userDefaults stringForKey: @"MessageForwarding"];
|
2007-08-22 17:18:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserMessageForwarding: (NSString *) newMessageForwarding
|
|
|
|
{
|
|
|
|
[userDefaults setObject: newMessageForwarding forKey: @"MessageForwarding"];
|
|
|
|
}
|
|
|
|
|
2007-11-06 18:13:15 +01:00
|
|
|
// <label><var:string label:value="Default identity:"/>
|
|
|
|
// <var:popup list="identitiesList" item="item"
|
|
|
|
// string="itemIdentityText" selection="defaultIdentity"/></label>
|
|
|
|
- (NSArray *) identitiesList
|
|
|
|
{
|
2007-11-19 23:44:12 +01:00
|
|
|
NSDictionary *primaryAccount;
|
|
|
|
|
|
|
|
#warning we manage only one account per user at this time...
|
|
|
|
primaryAccount = [[user mailAccounts] objectAtIndex: 0];
|
|
|
|
|
|
|
|
return [primaryAccount objectForKey: @"identities"];
|
2007-11-06 18:13:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemIdentityText
|
|
|
|
{
|
2007-11-26 21:41:59 +01:00
|
|
|
return [(NSDictionary *) item keysWithFormat: @"%{fullName} <%{email}>"];
|
2007-11-06 18:13:15 +01:00
|
|
|
}
|
|
|
|
|
2007-11-19 23:44:12 +01:00
|
|
|
- (NSString *) signature
|
|
|
|
{
|
2008-02-07 17:53:19 +01:00
|
|
|
return [[user defaultIdentity] objectForKey: @"signature"];
|
2007-11-19 23:44:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setSignature: (NSString *) newSignature
|
|
|
|
{
|
2008-02-07 17:53:19 +01:00
|
|
|
[[user defaultIdentity] setObject: newSignature
|
2007-11-19 23:44:12 +01:00
|
|
|
forKey: @"signature"];
|
2008-02-07 17:53:19 +01:00
|
|
|
[user saveMailAccounts];
|
2007-11-19 23:44:12 +01:00
|
|
|
}
|
|
|
|
|
2008-09-28 21:49:17 +02:00
|
|
|
- (NSArray *) replyPlacementList
|
|
|
|
{
|
|
|
|
return [NSArray arrayWithObjects: @"above", @"below", nil];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemReplyPlacementText
|
|
|
|
{
|
|
|
|
return [self labelForKey:
|
|
|
|
[NSString stringWithFormat: @"replyplacement_%@", item]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userReplyPlacement
|
|
|
|
{
|
2008-10-29 20:23:31 +01:00
|
|
|
return [userDefaults stringForKey: @"ReplyPlacement"];
|
2008-09-28 21:49:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserReplyPlacement: (NSString *) newReplyPlacement
|
|
|
|
{
|
|
|
|
[userDefaults setObject: newReplyPlacement forKey: @"ReplyPlacement"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) signaturePlacementList
|
|
|
|
{
|
|
|
|
return [NSArray arrayWithObjects: @"above", @"below", nil];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemSignaturePlacementText
|
|
|
|
{
|
|
|
|
return [self labelForKey:
|
|
|
|
[NSString stringWithFormat: @"signatureplacement_%@", item]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userSignaturePlacement
|
|
|
|
{
|
2008-10-29 20:23:31 +01:00
|
|
|
return [userDefaults stringForKey: @"SignaturePlacement"];
|
2008-09-28 21:49:17 +02:00
|
|
|
}
|
|
|
|
|
2009-06-23 19:53:18 +02:00
|
|
|
- (NSArray *) composeMessagesType
|
|
|
|
{
|
|
|
|
return [NSArray arrayWithObjects: @"text", @"html", nil];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemComposeMessagesText
|
|
|
|
{
|
|
|
|
return [self labelForKey: [NSString stringWithFormat: @"composemessagestype_%@", item]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userComposeMessagesType
|
|
|
|
{
|
|
|
|
return [userDefaults stringForKey: @"ComposeMessagesType"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserComposeMessagesType: (NSString *) newType
|
|
|
|
{
|
|
|
|
[userDefaults setObject: newType forKey: @"ComposeMessagesType"];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-09-28 21:49:17 +02:00
|
|
|
- (void) setUserSignaturePlacement: (NSString *) newSignaturePlacement
|
|
|
|
{
|
|
|
|
[userDefaults setObject: newSignaturePlacement forKey: @"SignaturePlacement"];
|
|
|
|
}
|
|
|
|
|
2007-06-19 19:58:21 +02:00
|
|
|
- (id <WOActionResults>) defaultAction
|
|
|
|
{
|
|
|
|
id <WOActionResults> results;
|
|
|
|
WORequest *request;
|
2008-07-25 20:44:31 +02:00
|
|
|
NSString *method;
|
2007-06-19 19:58:21 +02:00
|
|
|
|
|
|
|
request = [context request];
|
|
|
|
if ([[request method] isEqualToString: @"POST"])
|
|
|
|
{
|
|
|
|
[userDefaults synchronize];
|
2008-07-25 20:44:31 +02:00
|
|
|
if (hasChanged)
|
|
|
|
method = @"window.location.reload()";
|
|
|
|
else
|
|
|
|
method = nil;
|
|
|
|
results = [self jsCloseWithRefreshMethod: method];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
results = self;
|
|
|
|
|
|
|
|
return results;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) shouldTakeValuesFromRequest: (WORequest *) request
|
|
|
|
inContext: (WOContext*) context
|
|
|
|
{
|
|
|
|
return [[request method] isEqualToString: @"POST"];
|
|
|
|
}
|
|
|
|
|
2007-11-26 21:41:59 +01:00
|
|
|
- (BOOL) userHasCalendarAccess
|
|
|
|
{
|
|
|
|
return [user canAccessModule: @"Calendar"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) userHasMailAccess
|
|
|
|
{
|
|
|
|
return [user canAccessModule: @"Mail"];
|
|
|
|
}
|
|
|
|
|
2008-08-21 04:36:04 +02:00
|
|
|
- (BOOL) shouldDisplayAdditionalPreferences
|
|
|
|
{
|
|
|
|
return shouldDisplayAdditionalPreferences;
|
|
|
|
}
|
|
|
|
|
2007-07-22 22:17:34 +02:00
|
|
|
- (BOOL) shouldDisplayPasswordChange
|
|
|
|
{
|
|
|
|
return shouldDisplayPasswordChange;
|
|
|
|
}
|
|
|
|
|
2009-07-16 17:57:31 +02:00
|
|
|
- (NSString *) nameLabel
|
|
|
|
{
|
|
|
|
return [self labelForKey: @"Name"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) colorLabel
|
|
|
|
{
|
|
|
|
return [self labelForKey: @"Color"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) categories
|
|
|
|
{
|
|
|
|
NSDictionary *element;
|
|
|
|
NSArray *k, *v, *names;
|
|
|
|
NSMutableArray *rc, *colors;
|
|
|
|
int i, count;
|
|
|
|
|
|
|
|
names = [userDefaults arrayForKey: @"CalendarCategories"];
|
|
|
|
if (names)
|
|
|
|
colors = [NSMutableArray arrayWithArray:
|
|
|
|
[userDefaults arrayForKey: @"CalendarCategoriesColors"]];
|
|
|
|
else
|
|
|
|
{
|
|
|
|
names = [[self labelForKey: @"category_labels"]
|
|
|
|
componentsSeparatedByString: @","];
|
|
|
|
|
|
|
|
count = [names count];
|
|
|
|
colors = [NSMutableArray arrayWithCapacity: count];
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
[colors addObject: @"#F0F0F0"];
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = [NSMutableArray array];
|
|
|
|
k = [NSArray arrayWithObjects: @"name", @"color", nil];
|
|
|
|
|
|
|
|
count = [names count];
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
v = [NSArray arrayWithObjects: [names objectAtIndex: i],
|
|
|
|
[colors objectAtIndex: i], nil];
|
|
|
|
|
|
|
|
element = [NSDictionary dictionaryWithObjects: v
|
|
|
|
forKeys: k];
|
|
|
|
[rc addObject: element];
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (NSString *) categoriesValue
|
|
|
|
{
|
|
|
|
return @"";
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setCategoriesValue: (NSString *) value
|
|
|
|
{
|
|
|
|
NSData *data;
|
|
|
|
NSString *error;
|
|
|
|
NSPropertyListFormat format;
|
|
|
|
NSDictionary *plist;
|
|
|
|
|
|
|
|
data = [value dataUsingEncoding: NSUTF8StringEncoding];
|
|
|
|
plist = [NSPropertyListSerialization propertyListFromData: data
|
|
|
|
mutabilityOption: NSPropertyListImmutable
|
|
|
|
format: &format
|
|
|
|
errorDescription: &error];
|
|
|
|
|
|
|
|
if(!plist)
|
|
|
|
{
|
|
|
|
NSLog(error);
|
|
|
|
[error release];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[userDefaults setObject: [plist objectAtIndex: 0]
|
|
|
|
forKey: @"CalendarCategories"];
|
|
|
|
[userDefaults setObject: [plist objectAtIndex: 1]
|
|
|
|
forKey: @"CalendarCategoriesColors"];
|
|
|
|
NSLog ([plist description]);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-06-19 19:58:21 +02:00
|
|
|
@end
|