From a6ff43403ca225d9e907d46e7c17a01c529b1e31 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Thu, 29 Mar 2007 18:01:08 +0000 Subject: [PATCH] Monotone-Parent: 85dc43fda460dac5c674691569ef28456370a662 Monotone-Revision: 2efefcff9ab0da5d85dda51fd6f6d5e0dda566f0 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-03-29T18:01:08 Monotone-Branch: ca.inverse.sogo --- UI/Scheduler/UIxCalCalendarsListView.h | 42 ----- UI/Scheduler/UIxCalCalendarsListView.m | 215 ------------------------- 2 files changed, 257 deletions(-) delete mode 100644 UI/Scheduler/UIxCalCalendarsListView.h delete mode 100644 UI/Scheduler/UIxCalCalendarsListView.m diff --git a/UI/Scheduler/UIxCalCalendarsListView.h b/UI/Scheduler/UIxCalCalendarsListView.h deleted file mode 100644 index e3ed293e6..000000000 --- a/UI/Scheduler/UIxCalCalendarsListView.h +++ /dev/null @@ -1,42 +0,0 @@ -/* UIxCalCalendarsListView.h - this file is part of SOGo - * - * Copyright (C) 2006 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 UIXCALCALENDARSLISTVIEW_H -#define UIXCALCALENDARSLISTVIEW_H - -#import - -@class NSMutableArray; -@class NSMutableDictionary; -@class iCalPerson; - -@interface UIxCalCalendarsListView : UIxComponent -{ - NSMutableArray *checkedContacts; - NSMutableArray *contacts; - NSMutableDictionary *colors; - iCalPerson *currentContactPerson; -} - -@end - -#endif /* UIXCALCALENDARSLISTVIEW_H */ diff --git a/UI/Scheduler/UIxCalCalendarsListView.m b/UI/Scheduler/UIxCalCalendarsListView.m deleted file mode 100644 index b25de8200..000000000 --- a/UI/Scheduler/UIxCalCalendarsListView.m +++ /dev/null @@ -1,215 +0,0 @@ -/* UIxCalCalendarsListView.m - this file is part of SOGo - * - * Copyright (C) 2006 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 "UIxCalCalendarsListView.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; -} - -@implementation UIxCalCalendarsListView - -- (id) init -{ - if ((self = [super init])) - { - contacts = nil; - checkedContacts = nil; - currentContactPerson = nil; - colors = nil; - } - - return self; -} - -- (void) dealloc -{ - if (currentContactPerson) - [currentContactPerson release]; - if (contacts) - [contacts release]; - if (checkedContacts) - [checkedContacts release]; - if (colors) - [colors release]; - [super dealloc]; -} - -- (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; -} - -- (void) _addContactId: (NSString *) contactId - withUm: (AgenorUserManager *) um - andNumber: (unsigned int) count -{ - NSString *contactRealId; - iCalPerson *currentContact; - - if ([contactId hasPrefix: @"-"]) - contactRealId = [contactId substringFromIndex: 1]; - else - contactRealId = contactId; - - currentContact = [um iCalPersonWithUid: contactRealId]; - [contacts addObject: currentContact]; - if (contactId == contactRealId) - [checkedContacts addObject: currentContact]; - [colors setObject: [self _colorForNumber: count] - forKey: contactRealId]; -} - -- (void) _setupContacts -{ - SOGoUser *user; - NSString *list, *currentId; - NSEnumerator *rawContacts; - AgenorUserManager *um; - unsigned int count; - - contacts = [NSMutableArray new]; - checkedContacts = [NSMutableArray new]; - colors = [NSMutableDictionary new]; - - um = [AgenorUserManager sharedUserManager]; - user = [context activeUser]; - list = [[user userDefaults] stringForKey: @"calendaruids"]; - if ([list length] == 0) - list = [self shortUserNameForDisplay]; - - rawContacts - = [[list componentsSeparatedByString: @","] objectEnumerator]; - currentId = [rawContacts nextObject]; - count = 0; - while (currentId) - { - [self _addContactId: currentId withUm: um andNumber: count]; - currentId = [rawContacts nextObject]; - count++; - } -} - -- (NSArray *) contacts -{ - if (!contacts) - [self _setupContacts]; - - return contacts; -} - -- (NSArray *) checkedContacts -{ - if (!checkedContacts) - [self _setupContacts]; - - return checkedContacts; -} - -- (void) setCurrentContactPerson: (iCalPerson *) contact -{ - if (currentContactPerson) - [currentContactPerson release]; - currentContactPerson = contact; - if (currentContactPerson) - [currentContactPerson retain]; -} - -- (NSString *) currentContactLogin -{ - return [currentContactPerson cn]; -} - -- (NSString *) currentContactSpanBG -{ - return [colors objectForKey: [currentContactPerson cn]]; -} - -- (NSString *) currentContactAptBorder -{ - NSString *spanBG; - char cColor[8]; - unsigned int count; - - spanBG = [colors objectForKey: [currentContactPerson cn]]; - [spanBG getCString: cColor]; - cColor[7] = 0; - for (count = 1; count < 7; count++) - cColor[count] = darkenedColor(cColor[count]); - - return [NSString stringWithCString: cColor]; -} - -- (NSDictionary *) colors -{ - return colors; -} - -@end