From b662767a1b79ba8fc3cec7616f46b2dc0658ea56 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 29 Jun 2007 22:03:30 +0000 Subject: [PATCH] Monotone-Parent: 226f5c8184e0e67598bf0e0344b9b7174261fd30 Monotone-Revision: b5deb749839a9258b2e277f5efccc88fee07a073 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-06-29T22:03:30 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 9 ++++ SoObjects/Contacts/SOGoContactFolders.m | 58 +++++++++++++++++-------- 2 files changed, 50 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 84d88ed60..cbbe4a60d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2007-06-29 Wolfgang Sourdeau + * SoObjects/Contacts/SOGoContactFolders.m ([SOGoContactFolders + -appendPersonalSources]): add the "personal" folder to the list of + user folders even if it doesn't exist, so that it is created when + the user accesses it. + + * SoObjects/Contacts/SOGoContactGCSFolder.m ([SOGoContactGCSFolder + -folderIsMandatory]): returns YES if nameInContainer is set to + "personal", which is the default address book. + * SoObjects/Appointments/SOGoAppointmentFolder.m ([SOGoAppointmentFolder -folderIsMandatory]): returns YES since users must have one Calendar folder (one and only one). diff --git a/SoObjects/Contacts/SOGoContactFolders.m b/SoObjects/Contacts/SOGoContactFolders.m index 0aeeab8fc..f166515a0 100644 --- a/SoObjects/Contacts/SOGoContactFolders.m +++ b/SoObjects/Contacts/SOGoContactFolders.m @@ -72,15 +72,52 @@ [super dealloc]; } +- (void) _fetchPersonalFolders: (NSString *) sql + withChannel: (EOAdaptorChannel *) fc +{ + NSArray *attrs; + NSDictionary *row; + SOGoContactGCSFolder *ab; + BOOL hasPersonal; + NSString *key, *path; + + hasPersonal = NO; + [fc evaluateExpressionX: sql]; + attrs = [fc describeResults: NO]; + row = [fc fetchAttributes: attrs withZone: NULL]; + while (row) + { + ab = [SOGoContactGCSFolder + contactFolderWithName: [row objectForKey: @"c_path4"] + andDisplayName: [row objectForKey: @"c_foldername"] + inContainer: self]; + key = [row objectForKey: @"c_path4"]; + hasPersonal = (hasPersonal || [key isEqualToString: @"personal"]); + [ab setOCSPath: [NSString stringWithFormat: @"%@/%@", + OCSPath, key]]; + [contactFolders setObject: ab forKey: key]; + row = [fc fetchAttributes: attrs withZone: NULL]; + } + + if (!hasPersonal) + { + ab = [SOGoContactGCSFolder contactFolderWithName: @"personal" + andDisplayName: @"Contacts" + inContainer: self]; + path = [NSString stringWithFormat: + @"/Users/%@/Contacts/personal", + [self ownerInContext: context]]; + [ab setOCSPath: path]; + [contactFolders setObject: ab forKey: @"personal"]; + } +} + - (void) appendPersonalSources { - SOGoContactGCSFolder *ab; GCSChannelManager *cm; EOAdaptorChannel *fc; NSURL *folderLocation; NSString *sql; - NSArray *attrs; - NSDictionary *row; cm = [GCSChannelManager defaultChannelManager]; folderLocation @@ -93,20 +130,7 @@ @" WHERE c_path2 = '%@'" @" AND c_folder_type = 'Contact'"), [folderLocation gcsTableName], [self ownerInContext: context]]; - [fc evaluateExpressionX: sql]; - attrs = [fc describeResults: NO]; - row = [fc fetchAttributes: attrs withZone: NULL]; - while (row) - { - ab = [SOGoContactGCSFolder contactFolderWithName: [row objectForKey: @"c_path4"] - andDisplayName: [row objectForKey: @"c_foldername"] - inContainer: self]; - [ab setOCSPath: [NSString stringWithFormat: @"%@/%@", - OCSPath, [row objectForKey: @"c_path4"]]]; - [contactFolders setObject: ab forKey: [row objectForKey: @"c_path4"]]; - row = [fc fetchAttributes: attrs withZone: NULL]; - } - + [self _fetchPersonalFolders: sql withChannel: fc]; [cm releaseChannel: fc]; // sql = [sql stringByAppendingFormat:@" WHERE %@ = '%@'", // uidColumnName, [self uid]];