The collected address book will be created only if the user select it in the preferences. Fix labels.

This commit is contained in:
Alexandre Cloutier
2014-03-27 15:27:48 -04:00
parent bce701208a
commit 1da1764aae
9 changed files with 59 additions and 47 deletions
+26 -33
View File
@@ -116,6 +116,7 @@ static NSArray *reminderValues = nil;
if ((self = [super init]))
{
item = nil;
addressBooksIDWithDisplayName = nil;
#warning user should be the owner rather than the activeUser
ASSIGN (user, [context activeUser]);
ASSIGN (today, [NSCalendarDate date]);
@@ -691,8 +692,9 @@ static NSArray *reminderValues = nil;
- (NSArray *) addressBookList
{
/* We want all the SourceIDS */
NSMutableArray *folders, *contactFolders, *availableAddressBooks;
NSMutableArray *folders, *contactFolders, *availableAddressBooksID, *availableAddressBooksName;
int i, count;
BOOL collectedAlreadyExist;
contactFolders = [[[context activeUser] homeFolderInContext: context]
lookupName: @"Contacts"
@@ -702,49 +704,40 @@ static NSArray *reminderValues = nil;
count = [folders count]-1;
// Inside this loop we remove all the public or shared addressbooks
for (count; count >= 0; count--)
for(count; count>=0; count--)
{
if (![[folders objectAtIndex: count] isKindOfClass: [SOGoContactGCSFolder class]])
[folders removeObjectAtIndex: count];
}
// Parse the objects in order to have only the displayName of the addressbooks to be displayed on the preferences interface
availableAddressBooks = [[NSMutableArray alloc] initWithCapacity: [folders count]];
availableAddressBooksID = [NSMutableArray arrayWithCapacity: [folders count]];
availableAddressBooksName = [NSMutableArray arrayWithCapacity: [folders count]];
count = [folders count]-1;
for (i=0; i <= count ; i++) {
[availableAddressBooks addObject:[[folders objectAtIndex:i] realNameInContainer]];
}
collectedAlreadyExist = false;
return availableAddressBooks;
for (i=0; i <= count ; i++) {
[availableAddressBooksID addObject:[[folders objectAtIndex:i] realNameInContainer]];
[availableAddressBooksName addObject:[[folders objectAtIndex:i] displayName]];
if ([[availableAddressBooksID objectAtIndex:i] isEqualToString: @"collected"])
collectedAlreadyExist = true;
}
// Create the dictionary for the next function : itemAddressBookText.
if (!addressBooksIDWithDisplayName)
addressBooksIDWithDisplayName = [NSMutableDictionary dictionaryWithObjects:availableAddressBooksName
forKeys:availableAddressBooksID];
if (!collectedAlreadyExist)
{
[availableAddressBooksID addObject: @"collected"];
[addressBooksIDWithDisplayName setObject: [self labelForKey: @"Collected Address Book"] forKey: @"collected"];
}
return availableAddressBooksID;
}
- (NSString *) itemAddressBookText
{
NSString *displayNameAddressBookItem, *test;
NSMutableArray *folders, *contactFolders;
int count, i;
if ([item isEqualToString: @"personal"] || [item isEqualToString: @"collected"])
displayNameAddressBookItem = [self labelForKey:[NSString stringWithFormat: item]];
else
{
contactFolders = [[[context activeUser] homeFolderInContext: context]
lookupName: @"Contacts"
inContext: context
acquire: NO];
folders = [NSMutableArray arrayWithArray: [contactFolders subFolders]];
count = [folders count]-1;
for (i=0; i <= count ; i++)
{
if ([item isEqualToString:[[folders objectAtIndex:i] realNameInContainer]])
{
displayNameAddressBookItem = [[folders objectAtIndex:i] displayName];
break;
};
}
}
return displayNameAddressBookItem;
return [addressBooksIDWithDisplayName objectForKey: item];
}
- (NSString *) userAddressBook