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/SOGoUser.h>
31 #import <SoObjects/Contacts/SOGoContactFolder.h>
33 #import "UIxContactsListViewContainer.h"
35 @class SOGoContactFolders;
37 @implementation UIxContactsListViewContainer
41 if ((self = [super init]))
44 selectorComponentClass = nil;
45 additionalFolders = nil;
53 [additionalFolders release];
57 - (void) setSelectorComponentClass: (NSString *) aComponentClass
59 selectorComponentClass = aComponentClass;
62 - (NSString *) selectorComponentName
64 return selectorComponentClass;
67 - (WOElement *) selectorComponent
69 WOElement *newComponent;
70 // Class componentClass;
72 // componentClass = NSClassFromString(selectorComponentClass);
73 // if (componentClass)
75 newComponent = [self pageWithName: selectorComponentClass];
78 // newComponent = nil;
83 - (void) setCurrentFolder: (id) folder
85 currentFolder = folder;
88 - (NSString *) foldersPrefix
90 NSMutableArray *folders;
91 SOGoObject *currentObject;
95 folders = [NSMutableArray new];
96 [folders autorelease];
98 currentObject = [[self clientObject] container];
99 while (![currentObject isKindOfClass: [SOGoContactFolders class]])
101 [folders insertObject: [currentObject nameInContainer] atIndex: 0];
102 currentObject = [currentObject container];
105 foldersPrefix = [folders componentsJoinedByString: @"/"];
106 [foldersPrefix retain];
109 return foldersPrefix;
112 - (NSArray *) contactFolders
114 SOGoContactFolders *folderContainer;
116 folderContainer = [[self clientObject] container];
118 return [folderContainer contactFolders];
121 - (NSString *) currentContactFolderId
123 return [NSString stringWithFormat: @"%@/%@",
124 [self foldersPrefix],
125 [currentFolder nameInContainer]];
128 - (NSString *) currentContactFolderName
130 return [currentFolder displayName];
133 - (NSArray *) additionalFolders
137 if (!additionalFolders)
139 ud = [[context activeUser] userSettings];
141 = [[ud objectForKey: @"Contacts"] objectForKey: @"SubscribedFolders"];
142 [additionalFolders retain];
145 return [additionalFolders allKeys];
148 - (void) setCurrentAdditionalFolder: (NSString *) newCurrentAdditionalFolder
150 currentAdditionalFolder = newCurrentAdditionalFolder;
153 - (NSString *) currentAdditionalFolder
155 return currentAdditionalFolder;
158 - (NSString *) currentAdditionalFolderName
160 return [[additionalFolders objectForKey: currentAdditionalFolder]
161 objectForKey: @"displayName"];
164 - (BOOL) hasContactSelectionButtons
166 return (selectorComponentClass != nil);
171 return [[self queryParameterForKey: @"popup"] boolValue];