1 /* UIxContactsListViewContainer.m - this file is part of SOGo
3 * Copyright (C) 2006 Inverse groupe conseil
5 * Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
7 * This file is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This file is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 #import <Foundation/NSArray.h>
24 #import <Foundation/NSDictionary.h>
25 #import <Foundation/NSString.h>
27 #import <NGObjWeb/SoObjects.h>
28 #import <NGExtensions/NSObject+Values.h>
30 #import <SoObjects/SOGo/AgenorUserManager.h>
31 #import <SoObjects/SOGo/SOGoUser.h>
32 #import <SoObjects/Contacts/SOGoContactFolder.h>
34 #import "UIxContactsListViewContainer.h"
36 @class SOGoContactFolders;
38 @implementation UIxContactsListViewContainer
42 if ((self = [super init]))
45 selectorComponentClass = nil;
46 additionalFolders = nil;
54 [additionalFolders release];
58 - (void) setSelectorComponentClass: (NSString *) aComponentClass
60 selectorComponentClass = aComponentClass;
63 - (NSString *) selectorComponentName
65 return selectorComponentClass;
68 - (WOElement *) selectorComponent
70 WOElement *newComponent;
71 // Class componentClass;
73 // componentClass = NSClassFromString(selectorComponentClass);
74 // if (componentClass)
76 newComponent = [self pageWithName: selectorComponentClass];
79 // newComponent = nil;
84 - (void) setCurrentFolder: (id) folder
86 currentFolder = folder;
89 - (NSString *) foldersPrefix
91 NSMutableArray *folders;
92 SOGoObject *currentObject;
96 folders = [NSMutableArray new];
97 [folders autorelease];
99 currentObject = [[self clientObject] container];
100 while (![currentObject isKindOfClass: [SOGoContactFolders class]])
102 [folders insertObject: [currentObject nameInContainer] atIndex: 0];
103 currentObject = [currentObject container];
106 foldersPrefix = [folders componentsJoinedByString: @"/"];
107 [foldersPrefix retain];
110 return foldersPrefix;
113 - (NSArray *) contactFolders
115 SOGoContactFolders *folderContainer;
117 folderContainer = [[self clientObject] container];
119 return [folderContainer contactFolders];
122 - (NSString *) currentContactFolderId
124 return [NSString stringWithFormat: @"%@/%@",
125 [self foldersPrefix],
126 [currentFolder nameInContainer]];
129 - (NSString *) currentContactFolderName
131 return [self labelForKey: [currentFolder displayName]];
134 - (NSArray *) additionalFolders
136 AgenorUserManager *um;
140 if (!additionalFolders)
142 um = [AgenorUserManager sharedUserManager];
143 login = [[context activeUser] login];
144 ud = [um getUserSettingsForUID: login];
146 = [[ud objectForKey: @"Contacts"] objectForKey: @"SubscribedFolders"];
147 [additionalFolders retain];
150 return [additionalFolders allKeys];
153 - (void) setCurrentAdditionalFolder: (NSString *) newCurrentAdditionalFolder
155 currentAdditionalFolder = newCurrentAdditionalFolder;
158 - (NSString *) currentAdditionalFolder
160 return currentAdditionalFolder;
163 - (NSString *) currentAdditionalFolderName
165 return [[additionalFolders objectForKey: currentAdditionalFolder]
166 objectForKey: @"displayName"];
169 - (BOOL) hasContactSelectionButtons
171 return (selectorComponentClass != nil);
176 return [[self queryParameterForKey: @"popup"] boolValue];