From 8faf83f55f482b86e7d6b15b5848f414e73ebe4e Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 4 Aug 2006 22:46:19 +0000 Subject: [PATCH] Monotone-Parent: 23e53c0473abebbb7c7be319abdfa337d6e21f12 Monotone-Revision: c2ee10fbf9266b5c8710519bc2fd13bae46e672b Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2006-08-04T22:46:19 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 6 + SoObjects/Contacts/SOGoContactFolders.h | 42 +++++++ SoObjects/Contacts/SOGoContactFolders.m | 146 ++++++++++++++++++++++++ 3 files changed, 194 insertions(+) create mode 100644 SoObjects/Contacts/SOGoContactFolders.h create mode 100644 SoObjects/Contacts/SOGoContactFolders.m diff --git a/ChangeLog b/ChangeLog index 8fe97d257..60fa4e014 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-08-04 Wolfgang Sourdeau + + * SoObjects/Contacts/SOGoContactFolders.[hm]: new class module + serving as the root of the contact folders available to the + current user. Correctly lists the contact sources in webdav. + 2006-08-03 Wolfgang Sourdeau * UI/MailerUI/UIxMailAccountsView.m ([UIxMailAccountsView diff --git a/SoObjects/Contacts/SOGoContactFolders.h b/SoObjects/Contacts/SOGoContactFolders.h new file mode 100644 index 000000000..f934b1bfe --- /dev/null +++ b/SoObjects/Contacts/SOGoContactFolders.h @@ -0,0 +1,42 @@ +/* SOGoContactFolders.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 SOGOCONTACTFOLDERS_H +#define SOGOCONTACTFOLDERS_H + +#import + +@class NSMutableDictionary; +@class NSString; + +@interface SOGoContactFolders : SOGoObject +{ + NSMutableDictionary *contactSources; + NSString *OCSPath; +} + +- (NSString *) defaultSourceName; +- (void) setBaseOCSPath: (NSString *) newOCSPath; + +@end + +#endif /* SOGOCONTACTFOLDERS_H */ diff --git a/SoObjects/Contacts/SOGoContactFolders.m b/SoObjects/Contacts/SOGoContactFolders.m new file mode 100644 index 000000000..aa0d2fe1e --- /dev/null +++ b/SoObjects/Contacts/SOGoContactFolders.m @@ -0,0 +1,146 @@ +/* SOGoContactFolders.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 "common.h" + +#import "SOGoContactFolder.h" +#import "SOGoContactSource.h" +#import "SOGoPersonalAB.h" + +#import "SOGoContactFolders.h" + +@implementation SOGoContactFolders + +- (id) init +{ + if ((self = [super init])) + { + contactSources = nil; + OCSPath = nil; + } + + return self; +} + +- (void) dealloc +{ + if (contactSources) + [contactSources release]; + if (OCSPath) + [OCSPath release]; + [super dealloc]; +} + +- (void) appendPersonalSourcesInContext: (WOContext *) context; +{ + SOGoPersonalAB *ab; + + ab = [SOGoPersonalAB personalABForUser: [[context activeUser] login]]; + [contactSources setObject: ab forKey: @"personal"]; +} + +- (void) appendSystemSourcesInContext: (WOContext *) context; +{ +} + +- (void) initContactSourcesInContext: (WOContext *) context; +{ + if (!contactSources) + { + contactSources = [NSMutableDictionary new]; + [self appendPersonalSourcesInContext: context]; + [self appendSystemSourcesInContext: context]; + } +} + +- (id) lookupName: (NSString *) name + inContext: (WOContext *) context + acquire: (BOOL) acquire +{ + id obj; + SOGoContactSource *source; + + /* first check attributes directly bound to the application */ + obj = [super lookupName: name inContext: context acquire: NO]; + if (!obj) + { + if (!contactSources) + [self initContactSourcesInContext: context]; + + source = [contactSources objectForKey: name]; + if (source) + { + obj = [SOGoContactFolder contactFolderWithSource: source + inContainer: self + andName: name]; + [obj setOCSPath: [NSString stringWithFormat: @"%@/%@", + OCSPath, name]]; + } + else + obj = [NSException exceptionWithHTTPStatus: 200]; + } + + return obj; +} + +- (NSArray *) toManyRelationshipKeys +{ + WOContext *context; + + if (!contactSources) + { + context = [[WOApplication application] context]; + [self initContactSourcesInContext: context]; + } + + return [contactSources allKeys]; +} + +- (BOOL) davIsCollection +{ + return YES; +} + +- (void) setBaseOCSPath: (NSString *) newOCSPath +{ + if (OCSPath) + [OCSPath release]; + OCSPath = newOCSPath; + if (OCSPath) + [OCSPath retain]; +} + +/* web interface */ +- (NSString *) defaultSourceName +{ + return @"personal"; +} + +@end