2006-08-05 00:46:19 +02:00
|
|
|
/* SOGoContactFolders.m - this file is part of SOGo
|
|
|
|
*
|
2008-09-27 03:13:41 +02:00
|
|
|
* Copyright (C) 2006, 2007 Inverse inc.
|
2006-08-05 00:46:19 +02:00
|
|
|
*
|
|
|
|
* 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-08-09 23:31:28 +02:00
|
|
|
/* MailItems IPF.Note
|
|
|
|
ContactItems IPF.Contact
|
|
|
|
AppointmentItems IPF.Appointment
|
|
|
|
NoteItems IPF.StickyNote
|
|
|
|
TaskItems IPF.Task
|
|
|
|
JournalItems IPF.Journal */
|
|
|
|
|
2007-09-11 22:17:39 +02:00
|
|
|
#import <Foundation/NSArray.h>
|
2008-07-10 17:11:33 +02:00
|
|
|
#import <Foundation/NSDictionary.h>
|
2006-08-05 00:46:19 +02:00
|
|
|
#import <Foundation/NSString.h>
|
2007-09-11 22:17:39 +02:00
|
|
|
#import <Foundation/NSEnumerator.h>
|
2006-08-05 00:46:19 +02:00
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
#import <NGObjWeb/WOContext+SoObjects.h>
|
|
|
|
#import <SOGo/SOGoUser.h>
|
|
|
|
#import <SOGo/SOGoUserManager.h>
|
2010-08-12 15:18:35 +02:00
|
|
|
#import <SOGo/WORequest+SOGo.h>
|
2006-12-15 23:18:55 +01:00
|
|
|
|
2006-08-09 23:31:28 +02:00
|
|
|
#import "SOGoContactGCSFolder.h"
|
2009-09-25 16:42:33 +02:00
|
|
|
#import "SOGoContactSourceFolder.h"
|
2006-08-05 00:46:19 +02:00
|
|
|
#import "SOGoContactFolders.h"
|
|
|
|
|
|
|
|
@implementation SOGoContactFolders
|
|
|
|
|
2007-09-11 22:17:39 +02:00
|
|
|
+ (NSString *) gcsFolderType
|
2006-08-05 00:46:19 +02:00
|
|
|
{
|
2007-09-11 22:17:39 +02:00
|
|
|
return @"Contact";
|
2006-08-05 00:46:19 +02:00
|
|
|
}
|
|
|
|
|
2007-09-11 22:17:39 +02:00
|
|
|
+ (Class) subFolderClass
|
2006-08-05 00:46:19 +02:00
|
|
|
{
|
2007-09-11 22:17:39 +02:00
|
|
|
return [SOGoContactGCSFolder class];
|
2007-02-09 22:18:28 +01:00
|
|
|
}
|
|
|
|
|
2009-03-23 14:10:33 +01:00
|
|
|
- (NSException *) appendSystemSources
|
2007-05-09 21:18:06 +02:00
|
|
|
{
|
2009-09-25 16:42:33 +02:00
|
|
|
SOGoUserManager *um;
|
2007-05-09 21:18:06 +02:00
|
|
|
NSEnumerator *sourceIDs;
|
2009-11-29 05:19:32 +01:00
|
|
|
NSString *currentSourceID, *srcDisplayName, *domain;
|
2009-09-25 16:42:33 +02:00
|
|
|
SOGoContactSourceFolder *currentFolder;
|
2010-06-02 18:37:43 +02:00
|
|
|
SOGoUser *currentUser;
|
2007-05-09 21:18:06 +02:00
|
|
|
|
2010-08-20 14:50:47 +02:00
|
|
|
if (![[context request] isIPhoneAddressBookApp])
|
2007-05-09 21:18:06 +02:00
|
|
|
{
|
2010-08-20 14:50:47 +02:00
|
|
|
currentUser = [context activeUser];
|
|
|
|
if (activeUserIsOwner
|
|
|
|
|| [[currentUser login] isEqualToString: owner])
|
2010-06-02 18:37:43 +02:00
|
|
|
{
|
2010-08-20 14:50:47 +02:00
|
|
|
domain = [currentUser domain];
|
|
|
|
um = [SOGoUserManager sharedUserManager];
|
|
|
|
sourceIDs = [[um addressBookSourceIDsInDomain: domain]
|
|
|
|
objectEnumerator];
|
|
|
|
while ((currentSourceID = [sourceIDs nextObject]))
|
|
|
|
{
|
|
|
|
srcDisplayName
|
|
|
|
= [um displayNameForSourceWithID: currentSourceID];
|
|
|
|
currentFolder = [SOGoContactSourceFolder
|
|
|
|
folderWithName: currentSourceID
|
|
|
|
andDisplayName: srcDisplayName
|
|
|
|
inContainer: self];
|
|
|
|
[currentFolder setSource: [um sourceWithID: currentSourceID]];
|
|
|
|
[subFolders setObject: currentFolder forKey: currentSourceID];
|
|
|
|
}
|
2010-06-02 18:37:43 +02:00
|
|
|
}
|
2007-05-09 21:18:06 +02:00
|
|
|
}
|
2009-03-23 14:10:33 +01:00
|
|
|
|
|
|
|
return nil;
|
2007-05-09 21:18:06 +02:00
|
|
|
}
|
2010-08-20 14:50:47 +02:00
|
|
|
|
2007-09-15 00:01:02 +02:00
|
|
|
- (NSString *) defaultFolderName
|
|
|
|
{
|
2008-06-23 16:23:18 +02:00
|
|
|
return [self labelForKey: @"Personal Address Book"];
|
2007-09-15 00:01:02 +02:00
|
|
|
}
|
|
|
|
|
2010-08-12 15:18:35 +02:00
|
|
|
- (NSArray *) toManyRelationshipKeys
|
|
|
|
{
|
|
|
|
NSMutableArray *keys;
|
|
|
|
|
2010-08-20 14:50:47 +02:00
|
|
|
if ([[context request] isMacOSXAddressBookApp])
|
2010-08-12 15:18:35 +02:00
|
|
|
keys = [NSMutableArray arrayWithObject: @"personal"];
|
|
|
|
else
|
|
|
|
keys = (NSMutableArray *) [super toManyRelationshipKeys];
|
|
|
|
|
|
|
|
return keys;
|
|
|
|
}
|
|
|
|
|
2006-08-05 00:46:19 +02:00
|
|
|
@end
|