2006-08-14 22:41:04 +02:00
|
|
|
/* UIxContactsListViewContainer.m - this file is part of SOGo
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Inverse groupe conseil
|
|
|
|
*
|
|
|
|
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2006-10-04 00:05:11 +02:00
|
|
|
#import <Foundation/NSArray.h>
|
2007-03-29 20:17:47 +02:00
|
|
|
#import <Foundation/NSDictionary.h>
|
2006-10-04 00:05:11 +02:00
|
|
|
#import <Foundation/NSString.h>
|
|
|
|
|
|
|
|
#import <NGObjWeb/SoObjects.h>
|
2006-11-01 21:38:57 +01:00
|
|
|
#import <NGExtensions/NSObject+Values.h>
|
2006-10-04 00:05:11 +02:00
|
|
|
|
2006-11-01 21:38:57 +01:00
|
|
|
#import <SoObjects/SOGo/SOGoUser.h>
|
2006-10-04 00:05:11 +02:00
|
|
|
#import <SoObjects/Contacts/SOGoContactFolder.h>
|
|
|
|
|
2006-08-14 22:41:04 +02:00
|
|
|
#import "UIxContactsListViewContainer.h"
|
|
|
|
|
2006-10-04 00:05:11 +02:00
|
|
|
@class SOGoContactFolders;
|
|
|
|
|
2006-08-14 22:41:04 +02:00
|
|
|
@implementation UIxContactsListViewContainer
|
|
|
|
|
2006-10-04 00:05:11 +02:00
|
|
|
- (id) init
|
|
|
|
{
|
|
|
|
if ((self = [super init]))
|
|
|
|
{
|
|
|
|
foldersPrefix = nil;
|
|
|
|
selectorComponentClass = nil;
|
2007-03-29 20:17:47 +02:00
|
|
|
additionalFolders = nil;
|
2006-10-04 00:05:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2007-03-29 20:17:47 +02:00
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
[additionalFolders release];
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
2006-10-04 00:05:11 +02:00
|
|
|
- (void) setSelectorComponentClass: (NSString *) aComponentClass
|
|
|
|
{
|
|
|
|
selectorComponentClass = aComponentClass;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) selectorComponentName
|
|
|
|
{
|
|
|
|
return selectorComponentClass;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (WOElement *) selectorComponent
|
|
|
|
{
|
|
|
|
WOElement *newComponent;
|
|
|
|
// Class componentClass;
|
|
|
|
|
|
|
|
// componentClass = NSClassFromString(selectorComponentClass);
|
|
|
|
// if (componentClass)
|
|
|
|
// {
|
|
|
|
newComponent = [self pageWithName: selectorComponentClass];
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// newComponent = nil;
|
|
|
|
|
|
|
|
return newComponent;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setCurrentFolder: (id) folder
|
|
|
|
{
|
|
|
|
currentFolder = folder;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) foldersPrefix
|
|
|
|
{
|
|
|
|
NSMutableArray *folders;
|
|
|
|
SOGoObject *currentObject;
|
|
|
|
|
|
|
|
if (!foldersPrefix)
|
|
|
|
{
|
|
|
|
folders = [NSMutableArray new];
|
|
|
|
[folders autorelease];
|
|
|
|
|
|
|
|
currentObject = [[self clientObject] container];
|
|
|
|
while (![currentObject isKindOfClass: [SOGoContactFolders class]])
|
|
|
|
{
|
|
|
|
[folders insertObject: [currentObject nameInContainer] atIndex: 0];
|
|
|
|
currentObject = [currentObject container];
|
|
|
|
}
|
|
|
|
|
|
|
|
foldersPrefix = [folders componentsJoinedByString: @"/"];
|
|
|
|
[foldersPrefix retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
return foldersPrefix;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) contactFolders
|
|
|
|
{
|
|
|
|
SOGoContactFolders *folderContainer;
|
|
|
|
|
|
|
|
folderContainer = [[self clientObject] container];
|
|
|
|
|
|
|
|
return [folderContainer contactFolders];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) currentContactFolderId
|
|
|
|
{
|
|
|
|
return [NSString stringWithFormat: @"%@/%@",
|
|
|
|
[self foldersPrefix],
|
|
|
|
[currentFolder nameInContainer]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) currentContactFolderName
|
|
|
|
{
|
2007-05-09 21:23:45 +02:00
|
|
|
return [currentFolder displayName];
|
2006-10-04 00:05:11 +02:00
|
|
|
}
|
|
|
|
|
2006-11-01 21:38:57 +01:00
|
|
|
- (NSArray *) additionalFolders
|
|
|
|
{
|
2007-03-29 20:17:47 +02:00
|
|
|
NSUserDefaults *ud;
|
2006-11-03 20:39:54 +01:00
|
|
|
|
2007-03-29 20:17:47 +02:00
|
|
|
if (!additionalFolders)
|
|
|
|
{
|
2007-05-09 21:23:45 +02:00
|
|
|
ud = [[context activeUser] userSettings];
|
2007-03-29 20:17:47 +02:00
|
|
|
additionalFolders
|
|
|
|
= [[ud objectForKey: @"Contacts"] objectForKey: @"SubscribedFolders"];
|
|
|
|
[additionalFolders retain];
|
|
|
|
}
|
2006-11-03 20:39:54 +01:00
|
|
|
|
2007-03-29 20:17:47 +02:00
|
|
|
return [additionalFolders allKeys];
|
2006-11-01 21:38:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setCurrentAdditionalFolder: (NSString *) newCurrentAdditionalFolder
|
|
|
|
{
|
|
|
|
currentAdditionalFolder = newCurrentAdditionalFolder;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) currentAdditionalFolder
|
|
|
|
{
|
|
|
|
return currentAdditionalFolder;
|
|
|
|
}
|
|
|
|
|
2007-03-29 20:17:47 +02:00
|
|
|
- (NSString *) currentAdditionalFolderName
|
|
|
|
{
|
|
|
|
return [[additionalFolders objectForKey: currentAdditionalFolder]
|
|
|
|
objectForKey: @"displayName"];
|
|
|
|
}
|
|
|
|
|
2006-10-04 00:05:11 +02:00
|
|
|
- (BOOL) hasContactSelectionButtons
|
|
|
|
{
|
|
|
|
return (selectorComponentClass != nil);
|
|
|
|
}
|
|
|
|
|
2006-11-01 21:38:57 +01:00
|
|
|
- (BOOL) isPopup
|
|
|
|
{
|
|
|
|
return [[self queryParameterForKey: @"popup"] boolValue];
|
|
|
|
}
|
|
|
|
|
2006-08-14 22:41:04 +02:00
|
|
|
@end
|