From: wolfgang Date: Thu, 29 Mar 2007 20:30:43 +0000 (+0000) Subject: git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1036 d1b88da0-ebda-0310... X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14a7e18940b6879221f9bf1f8f57a8cf12272132;p=scalable-opengroupware.org git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1036 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/SoObjects/Mailer/SOGoMailFolder.m b/SoObjects/Mailer/SOGoMailFolder.m index 00db1a0e..4204e881 100644 --- a/SoObjects/Mailer/SOGoMailFolder.m +++ b/SoObjects/Mailer/SOGoMailFolder.m @@ -320,7 +320,7 @@ static BOOL useAltNamespace = NO; } - (NSException *)delete { - /* Note: overrides SOGoObject -delete */o + /* Note: overrides SOGoObject -delete */ return [[self imap4Connection] deleteMailboxAtURL:[self imap4URL]]; } diff --git a/UI/Scheduler/UIxCalendarSelector.h b/UI/Scheduler/UIxCalendarSelector.h new file mode 100644 index 00000000..3d15fc77 --- /dev/null +++ b/UI/Scheduler/UIxCalendarSelector.h @@ -0,0 +1,52 @@ +/* UIxCalendarSelector.h - this file is part of SOGo + * + * Copyright (C) 2007 Inverse groupe conseil + * + * Author: Wolfgang Sourdeau + * + * 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. + */ + +#ifndef UIXCALENDARSELECTOR_H +#define UIXCALENDARSELECTOR_H + +@class NSArray; +@class NSMutableArray; +@class NSDictionary; +@class NSMutableDictionary; +@class NSString; +@class iCalPerson; + +@interface UIxCalendarSelector : UIxComponent +{ + NSMutableArray *calendarFolders; + NSMutableDictionary *colors; + + NSDictionary *currentCalendarFolder; + NSString *currentCalendarLogin; +} + +- (NSArray *) calendarFolders; +- (void) setCurrentCalendarFolder: (NSDictionary *) newCurrentCalendarFolder; +- (NSDictionary *) currentCalendarFolder; + +- (NSString *) currentCalendarSpanBG; +- (NSString *) currentCalendarLogin; +- (NSString *) currentCalendarStyle; + +@end + +#endif /* UIXCALENDARSELECTOR_H */ diff --git a/UI/Scheduler/UIxCalendarSelector.m b/UI/Scheduler/UIxCalendarSelector.m new file mode 100644 index 00000000..ab6b124a --- /dev/null +++ b/UI/Scheduler/UIxCalendarSelector.m @@ -0,0 +1,175 @@ +/* UIxCalendarSelector.m - this file is part of SOGo + * + * Copyright (C) 2007 Inverse groupe conseil + * + * Author: Wolfgang Sourdeau + * + * 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 +#import +#import +#import + +#import +#import + +#import +#import +#import + +#import "UIxCalendarSelector.h" + +static inline char +darkenedColor (const char value) +{ + char newValue; + + if (value >= '0' && value <= '9') + newValue = ((value - '0') / 2) + '0'; + else if (value >= 'a' && value <= 'f') + newValue = ((value + 10 - 'a') / 2) + '0'; + else if (value >= 'A' && value <= 'F') + newValue = ((value + 10 - 'A') / 2) + '0'; + else + newValue = value; + + return newValue; +} + +static inline NSString * +colorForNumber (unsigned int number) +{ + unsigned int index, currentValue; + unsigned char colorTable[] = { 1, 1, 1 }; + NSString *color; + + if (number == 0) + color = @"#ccf"; + else if (number == NSNotFound) + color = @"#f00"; + else + { + currentValue = number; + index = 0; + while (currentValue) + { + if (currentValue & 1) + colorTable[index]++; + if (index == 3) + index = 0; + currentValue >>= 1; + index++; + } + color = [NSString stringWithFormat: @"#%2x%2x%2x", + (255 / colorTable[2]) - 1, + (255 / colorTable[1]) - 1, + (255 / colorTable[0]) - 1]; + } + + return color; +} + +@implementation UIxCalendarSelector + +- (id) init +{ + if ((self = [super init])) + { + colors = [NSMutableDictionary new]; + calendarFolders = nil; + currentCalendarFolder = nil; + } + + return self; +} + +- (void) dealloc +{ + [calendarFolders release]; + [currentCalendarFolder release]; + [colors release]; + [super dealloc]; +} + +- (void) setCalendarFolders: (NSArray *) newCalendarFolders +{ + NSEnumerator *newFolders; + NSDictionary *currentFolder; + unsigned int count; + + ASSIGN (calendarFolders, newCalendarFolders); + + newFolders = [calendarFolders objectEnumerator]; + currentFolder = [newFolders nextObject]; + count = 0; + while (currentFolder) + { + [colors setObject: colorForNumber (count) + forKey: [currentFolder objectForKey: @"folder"]]; + count++; + currentFolder = [newFolders nextObject]; + } +} + +- (NSArray *) calendarFolders +{ + return calendarFolders; +} + +- (void) setCurrentCalendarFolder: (NSDictionary *) newCurrentCalendarFolder +{ + ASSIGN (currentCalendarFolder, newCurrentCalendarFolder); +} + +- (NSDictionary *) currentCalendarFolder +{ + return currentCalendarFolder; +} + +- (NSString *) currentCalendarSpanBG +{ + NSString *colorKey; + + colorKey = [currentCalendarFolder objectForKey: @"folder"]; + + return [colors objectForKey: colorKey]; +} + +- (NSString *) currentCalendarLogin +{ + NSArray *parts; + + parts = [[currentCalendarFolder objectForKey: @"folder"] + componentsSeparatedByString: @":"]; + + return (([parts count] > 1) + ? [parts objectAtIndex: 0] + : [[context activeUser] login]); +} + +- (NSString *) currentCalendarStyle +{ + NSString *color; + + color = [self currentCalendarSpanBG]; + + return [NSString stringWithFormat: @"color: %@; background-color: %@;", + color, color]; +} + +@end /* UIxCalendarSelector */