mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-10-19 10:08:12 +00:00
Monotone-Parent: 1a0f96fd588d7f7edaa7a85a352ab39c2acbca70
Monotone-Revision: b0d54fb9b69827b08042c1be219b87648b1a9df2 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-12-01T16:53:15 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
1 parent
ee001b16ab
commit
b9a5c1e750
8 files changed
+127
-69
No files matched your search
@@ -5,6 +5,26 @@
|
|||||||
|
|
||||||
2009-12-01 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
2009-12-01 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||||
|
|
||||||
|
* UI/PreferencesUI/UIxPreferences.m (-categoryList): simplified
|
||||||
|
method by returning only the array of defined categories from the
|
||||||
|
user defaults or those defined in the Localizable.strings and sort
|
||||||
|
the resulting array.
|
||||||
|
(-categoryColor): new accessor that return the color associated
|
||||||
|
with the value in the "category" ivar, if not exists, we return
|
||||||
|
the default from SOGoCalendarDefaultCategoryColor.
|
||||||
|
(-setCategoriesValue): simplified method since we now receive a
|
||||||
|
dictionary. The dictionary is now transferred as a JSON object
|
||||||
|
rather than a property list.
|
||||||
|
|
||||||
|
* SoObjects/SOGo/SOGoUserDefaults.m
|
||||||
|
(-setCalendarCategoriesColors:, -calendarCategoriesColors):
|
||||||
|
SOGoCalendarCategoriesColors is now a dictionary. The values are
|
||||||
|
migrated in _migrateCalendarCategories.
|
||||||
|
|
||||||
|
* SoObjects/SOGo/SOGoDomainDefaults.m
|
||||||
|
(-calendarDefaultCategoryColor): new accessor for the domain
|
||||||
|
default SOGoCalendarDefaultCategoryColor.
|
||||||
|
|
||||||
* SoObjects/SOGo/SOGoDefaultsSource.m (-boolForKey:)
|
* SoObjects/SOGo/SOGoDefaultsSource.m (-boolForKey:)
|
||||||
(-floatForKey:, -integerForKey:, -dataForKey:, -stringForKey:)
|
(-floatForKey:, -integerForKey:, -dataForKey:, -stringForKey:)
|
||||||
(-dictionaryForKey:, -arrayForKey:, -stringArrayForKey:): added
|
(-dictionaryForKey:, -arrayForKey:, -stringArrayForKey:): added
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
#import "NSDictionary+Utilities.h"
|
#import "NSDictionary+Utilities.h"
|
||||||
#import "SOGoStartupLogger.h"
|
#import "SOGoStartupLogger.h"
|
||||||
|
|
||||||
#define NEEDS_DEFAULTS_SOURCE_INTERNAL 1
|
|
||||||
#import "SOGoSystemDefaults.h"
|
#import "SOGoSystemDefaults.h"
|
||||||
|
|
||||||
@implementation SOGoSystemDefaults
|
@implementation SOGoSystemDefaults
|
||||||
|
|||||||
@@ -125,8 +125,8 @@ extern NSString *SOGoWeekStartFirstFullWeek;
|
|||||||
- (void) setCalendarCategories: (NSArray *) newValues;
|
- (void) setCalendarCategories: (NSArray *) newValues;
|
||||||
- (NSArray *) calendarCategories;
|
- (NSArray *) calendarCategories;
|
||||||
|
|
||||||
- (void) setCalendarCategoriesColors: (NSArray *) newValues;
|
- (void) setCalendarCategoriesColors: (NSDictionary *) newValues;
|
||||||
- (NSArray *) calendarCategoriesColors;
|
- (NSDictionary *) calendarCategoriesColors;
|
||||||
|
|
||||||
- (void) setCalendarShouldDisplayWeekend: (BOOL) newValue;
|
- (void) setCalendarShouldDisplayWeekend: (BOOL) newValue;
|
||||||
- (BOOL) calendarShouldDisplayWeekend;
|
- (BOOL) calendarShouldDisplayWeekend;
|
||||||
|
|||||||
@@ -26,7 +26,6 @@
|
|||||||
#import <Foundation/NSTimeZone.h>
|
#import <Foundation/NSTimeZone.h>
|
||||||
|
|
||||||
#import "NSString+Utilities.h"
|
#import "NSString+Utilities.h"
|
||||||
#define NEEDS_DEFAULTS_SOURCE_INTERNAL 1
|
|
||||||
#import "SOGoDomainDefaults.h"
|
#import "SOGoDomainDefaults.h"
|
||||||
#import "SOGoSystemDefaults.h"
|
#import "SOGoSystemDefaults.h"
|
||||||
#import "SOGoUserProfile.h"
|
#import "SOGoUserProfile.h"
|
||||||
@@ -147,6 +146,33 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek";
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL) _migrateCalendarCategories
|
||||||
|
{
|
||||||
|
NSArray *categories, *colors;
|
||||||
|
NSDictionary *newColors;
|
||||||
|
BOOL rc;
|
||||||
|
|
||||||
|
colors = [source objectForKey: @"SOGoCalendarCategoriesColors"];
|
||||||
|
if ([colors isKindOfClass: [NSArray class]])
|
||||||
|
{
|
||||||
|
categories = [source objectForKey: @"SOGoCalendarCategories"];
|
||||||
|
if ([categories count] == [colors count])
|
||||||
|
{
|
||||||
|
newColors = [NSDictionary dictionaryWithObjects: colors
|
||||||
|
forKeys: categories];
|
||||||
|
[source setObject: newColors
|
||||||
|
forKey: @"SOGoCalendarCategoriesColors"];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
[source removeObjectForKey: @"SOGoCalendarCategoriesColors"];
|
||||||
|
rc = YES;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
rc = NO;
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL) migrate
|
- (BOOL) migrate
|
||||||
{
|
{
|
||||||
static NSDictionary *migratedKeys = nil;
|
static NSDictionary *migratedKeys = nil;
|
||||||
@@ -185,6 +211,7 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek";
|
|||||||
not be invoked in the case where rc = YES. */
|
not be invoked in the case where rc = YES. */
|
||||||
return ([self _migrateLastModule]
|
return ([self _migrateLastModule]
|
||||||
| [self _migrateSignature]
|
| [self _migrateSignature]
|
||||||
|
| [self _migrateCalendarCategories]
|
||||||
| [self migrateOldDefaultsWithDictionary: migratedKeys]
|
| [self migrateOldDefaultsWithDictionary: migratedKeys]
|
||||||
| [super migrate]);
|
| [super migrate]);
|
||||||
}
|
}
|
||||||
@@ -490,14 +517,14 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek";
|
|||||||
return [self stringArrayForKey: @"SOGoCalendarCategories"];
|
return [self stringArrayForKey: @"SOGoCalendarCategories"];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setCalendarCategoriesColors: (NSArray *) newValues
|
- (void) setCalendarCategoriesColors: (NSDictionary *) newValues
|
||||||
{
|
{
|
||||||
[self setObject: newValues forKey: @"SOGoCalendarCategoriesColors"];
|
[self setObject: newValues forKey: @"SOGoCalendarCategoriesColors"];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray *) calendarCategoriesColors
|
- (NSDictionary *) calendarCategoriesColors
|
||||||
{
|
{
|
||||||
return [self stringArrayForKey: @"SOGoCalendarCategoriesColors"];
|
return [self dictionaryForKey: @"SOGoCalendarCategoriesColors"];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setCalendarShouldDisplayWeekend: (BOOL) newValue
|
- (void) setCalendarShouldDisplayWeekend: (BOOL) newValue
|
||||||
|
|||||||
@@ -35,6 +35,10 @@
|
|||||||
id item;
|
id item;
|
||||||
SOGoUser *user;
|
SOGoUser *user;
|
||||||
NSDictionary *locale;
|
NSDictionary *locale;
|
||||||
|
NSArray *calendarCategories;
|
||||||
|
NSDictionary *calendarCategoriesColors;
|
||||||
|
NSString *category;
|
||||||
|
NSString *defaultCategoryColor;
|
||||||
SOGoUserDefaults *userDefaults;
|
SOGoUserDefaults *userDefaults;
|
||||||
NSCalendarDate *today;
|
NSCalendarDate *today;
|
||||||
NSArray *daysOfWeek, *daysBetweenResponsesList;
|
NSArray *daysOfWeek, *daysBetweenResponsesList;
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
#import <NGExtensions/NSObject+Logs.h>
|
#import <NGExtensions/NSObject+Logs.h>
|
||||||
|
|
||||||
#import <SOGo/NSArray+Utilities.h>
|
#import <SOGo/NSArray+Utilities.h>
|
||||||
|
#import <SOGo/NSDictionary+BSJSONAdditions.h>
|
||||||
#import <SOGo/NSDictionary+Utilities.h>
|
#import <SOGo/NSDictionary+Utilities.h>
|
||||||
#import <SOGo/NSString+Utilities.h>
|
#import <SOGo/NSString+Utilities.h>
|
||||||
#import <SOGo/SOGoUser.h>
|
#import <SOGo/SOGoUser.h>
|
||||||
@@ -70,6 +71,11 @@
|
|||||||
//locale = [context valueForKey: @"locale"];
|
//locale = [context valueForKey: @"locale"];
|
||||||
language = [userDefaults language];
|
language = [userDefaults language];
|
||||||
|
|
||||||
|
calendarCategories = nil;
|
||||||
|
calendarCategoriesColors = nil;
|
||||||
|
defaultCategoryColor = nil;
|
||||||
|
category = nil;
|
||||||
|
|
||||||
ASSIGN (locale,
|
ASSIGN (locale,
|
||||||
[[WOApplication application] localeForLanguageNamed: language]);
|
[[WOApplication application] localeForLanguageNamed: language]);
|
||||||
ASSIGN (daysOfWeek, [locale objectForKey: NSWeekDayNameArray]);
|
ASSIGN (daysOfWeek, [locale objectForKey: NSWeekDayNameArray]);
|
||||||
@@ -108,6 +114,10 @@
|
|||||||
[user release];
|
[user release];
|
||||||
[userDefaults release];
|
[userDefaults release];
|
||||||
[vacationOptions release];
|
[vacationOptions release];
|
||||||
|
[calendarCategories release];
|
||||||
|
[calendarCategoriesColors release];
|
||||||
|
[defaultCategoryColor release];
|
||||||
|
[category release];
|
||||||
[forwardOptions release];
|
[forwardOptions release];
|
||||||
[daysOfWeek release];
|
[daysOfWeek release];
|
||||||
[locale release];
|
[locale release];
|
||||||
@@ -941,44 +951,60 @@
|
|||||||
return [self labelForKey: @"Color"];
|
return [self labelForKey: @"Color"];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray *) categories
|
- (NSArray *) languageCategories
|
||||||
{
|
{
|
||||||
NSDictionary *element;
|
NSArray *categoryLabels;
|
||||||
NSArray *k, *v, *names, *colors;
|
|
||||||
NSMutableArray *categories, *newColors;
|
|
||||||
int i, count;
|
|
||||||
|
|
||||||
names = [userDefaults calendarCategories];
|
categoryLabels = [[self labelForKey: @"category_labels"]
|
||||||
if (names)
|
componentsSeparatedByString: @","];
|
||||||
colors = [userDefaults calendarCategoriesColors];
|
|
||||||
else
|
|
||||||
{
|
|
||||||
names = [[self labelForKey: @"category_labels"]
|
|
||||||
componentsSeparatedByString: @","];
|
|
||||||
count = [names count];
|
|
||||||
newColors = [NSMutableArray arrayWithCapacity: count];
|
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
[newColors addObject: @"#F0F0F0"];
|
|
||||||
colors = newColors;
|
|
||||||
}
|
|
||||||
|
|
||||||
categories = [NSMutableArray array];
|
return [categoryLabels trimmedComponents];
|
||||||
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];
|
|
||||||
[categories addObject: element];
|
|
||||||
}
|
|
||||||
|
|
||||||
return categories;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSArray *) categoryList
|
||||||
|
{
|
||||||
|
if (!calendarCategories)
|
||||||
|
{
|
||||||
|
ASSIGN (calendarCategories, [userDefaults calendarCategories]);
|
||||||
|
if (!calendarCategories)
|
||||||
|
ASSIGN (calendarCategories, [self languageCategories]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [calendarCategories
|
||||||
|
sortedArrayUsingSelector: @selector (localizedCaseInsensitiveCompare:)];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setCategory: (NSString *) newCategory
|
||||||
|
{
|
||||||
|
ASSIGN (category, newCategory);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *) category
|
||||||
|
{
|
||||||
|
return category;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *) categoryColor
|
||||||
|
{
|
||||||
|
SOGoDomainDefaults *dd;
|
||||||
|
NSString *categoryColor;
|
||||||
|
|
||||||
|
if (!calendarCategoriesColors)
|
||||||
|
ASSIGN (calendarCategoriesColors, [userDefaults calendarCategoriesColors]);
|
||||||
|
|
||||||
|
categoryColor = [calendarCategoriesColors objectForKey: category];
|
||||||
|
if (!categoryColor)
|
||||||
|
{
|
||||||
|
if (!defaultCategoryColor)
|
||||||
|
{
|
||||||
|
dd = [[context activeUser] domainDefaults];
|
||||||
|
ASSIGN (defaultCategoryColor, [dd calendarDefaultCategoryColor]);
|
||||||
|
}
|
||||||
|
categoryColor = defaultCategoryColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
return categoryColor;
|
||||||
|
}
|
||||||
|
|
||||||
- (NSString *) categoriesValue
|
- (NSString *) categoriesValue
|
||||||
{
|
{
|
||||||
@@ -987,26 +1013,13 @@
|
|||||||
|
|
||||||
- (void) setCategoriesValue: (NSString *) value
|
- (void) setCategoriesValue: (NSString *) value
|
||||||
{
|
{
|
||||||
NSData *data;
|
NSDictionary *newColors;
|
||||||
NSString *error;
|
|
||||||
NSPropertyListFormat format;
|
|
||||||
NSArray *plist;
|
|
||||||
|
|
||||||
data = [value dataUsingEncoding: NSUTF8StringEncoding];
|
newColors = [NSMutableDictionary dictionaryWithJSONString: value];
|
||||||
plist = [NSPropertyListSerialization propertyListFromData: data
|
if (newColors)
|
||||||
mutabilityOption: NSPropertyListImmutable
|
|
||||||
format: &format
|
|
||||||
errorDescription: &error];
|
|
||||||
if (!plist)
|
|
||||||
{
|
{
|
||||||
[self errorWithFormat: @"an error occured during deserialization"
|
[userDefaults setCalendarCategories: [newColors allKeys]];
|
||||||
@" of categories: %@", error];
|
[userDefaults setCalendarCategoriesColors: newColors];
|
||||||
[error release];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
[userDefaults setCalendarCategories: [plist objectAtIndex: 0]];
|
|
||||||
[userDefaults setCalendarCategoriesColors: [plist objectAtIndex: 1]];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -108,12 +108,12 @@
|
|||||||
></tr
|
></tr
|
||||||
></thead>
|
></thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<var:foreach list="categories" item="category">
|
<var:foreach list="categoryList" item="category">
|
||||||
<tr const:class="categoryListRow"
|
<tr const:class="categoryListRow"
|
||||||
><td const:class="categoryListCell"
|
><td const:class="categoryListCell"
|
||||||
><var:string var:value="category.name"/></td
|
><var:string var:value="category"/></td
|
||||||
><td const:class="categoryListCell"
|
><td const:class="categoryListCell"
|
||||||
><div const:class="colorBox"><var:string var:value="category.color"
|
><div const:class="colorBox"><var:string var:value="categoryColor"
|
||||||
/></div></td
|
/></div></td
|
||||||
></tr>
|
></tr>
|
||||||
</var:foreach>
|
</var:foreach>
|
||||||
|
|||||||
@@ -245,21 +245,16 @@ function onCategoryDelete (e) {
|
|||||||
|
|
||||||
function serializeCategories (e) {
|
function serializeCategories (e) {
|
||||||
var r = $$("TABLE#categoriesList tbody tr");
|
var r = $$("TABLE#categoriesList tbody tr");
|
||||||
var names = "(";
|
|
||||||
var colors = "(";
|
|
||||||
|
|
||||||
|
var values = [];
|
||||||
for (var i = 0; i < r.length; i++) {
|
for (var i = 0; i < r.length; i++) {
|
||||||
var tds = r[i].childElements ();
|
var tds = r[i].childElements ();
|
||||||
var name = $(tds.first ()).innerHTML;
|
var name = $(tds.first ()).innerHTML;
|
||||||
var color = $(tds.last ().childElements ().first ()).showColor;
|
var color = $(tds.last ().childElements ().first ()).showColor;
|
||||||
|
values.push("\"" + name + "\": \"" + color + "\"");
|
||||||
names += "\"" + name + "\", ";
|
|
||||||
colors += "\"" + color + "\", ";
|
|
||||||
}
|
}
|
||||||
names = names.substr (0, names.length - 1) + ")";
|
|
||||||
colors = colors.substr (0, colors.length - 1) + ")";
|
|
||||||
|
|
||||||
$("categoriesValue").value = "(" + names + ", " + colors + ")";
|
$("categoriesValue").value = "{ " + values.join(",\n") + "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetCategoriesColors (e) {
|
function resetCategoriesColors (e) {
|
||||||
|
|||||||
Reference in new issue
Block a user