mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-22 03:45:25 +00:00
Mantis #5 completed, needs testing
Monotone-Parent: bb2d11200e5d8cbdc9a740b2a9e019efed65432b Monotone-Revision: 00f021939a59d6bcc0871dadde8fbc81c2d0b614 Monotone-Author: crobert@inverse.ca Monotone-Date: 2009-07-16T15:57:31 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSTimeZone.h>
|
||||
#import <Foundation/NSUserDefaults.h>
|
||||
#import <Foundation/NSPropertyList.h>
|
||||
|
||||
#import <NGObjWeb/WOContext.h>
|
||||
#import <NGObjWeb/WORequest.h>
|
||||
@@ -658,4 +659,88 @@ static BOOL defaultShowSubscribedFoldersOnly = NO;
|
||||
return shouldDisplayPasswordChange;
|
||||
}
|
||||
|
||||
- (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]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user