From b6201ae20a3cf135c093759498067eb759542e40 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Thu, 23 Oct 2008 15:35:20 +0000 Subject: [PATCH] Monotone-Parent: a93dd2767c4f017932c6339f82394fd558ef304f Monotone-Revision: 7e63e5fdd760a91e91ec6f1759064a5e5c2f267f Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-10-23T15:35:20 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 8 ++++++++ SoObjects/Mailer/SOGoMailAccounts.m | 8 ++------ SoObjects/Mailer/SOGoMailObject+Draft.m | 2 +- SoObjects/Mailer/SOGoMailObject.m | 7 ++++--- SoObjects/SOGo/NSArray+Utilities.h | 3 ++- SoObjects/SOGo/NSArray+Utilities.m | 6 +++++- SoObjects/SOGo/SOGoGCSFolder.m | 2 +- SoObjects/SOGo/SOGoUser.m | 4 ++-- UI/MailerUI/UIxMailListView.m | 6 +++--- UI/MailerUI/UIxMailMainFrame.m | 7 +++++-- 10 files changed, 33 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 76b94c163..0e7d46d36 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-10-23 Wolfgang Sourdeau + + * SoObjects/SOGo/NSArray+Utilities.m ([NSArray + -objectsForKey:keynotFoundMarker:marker]): added a + "notFoundMarker:" parameter to the "objectsForKey:" method. When + the marker is nil and no match is found in the current dictionary, + the entry is ignored. + 2008-10-21 Wolfgang Sourdeau * UI/Contacts/UIxContactFoldersView.m ([UIxContactFoldersView diff --git a/SoObjects/Mailer/SOGoMailAccounts.m b/SoObjects/Mailer/SOGoMailAccounts.m index cf498cf32..98727547e 100644 --- a/SoObjects/Mailer/SOGoMailAccounts.m +++ b/SoObjects/Mailer/SOGoMailAccounts.m @@ -47,18 +47,14 @@ accounts = [[context activeUser] mailAccounts]; - return [accounts objectsForKey: @"name"]; + return [accounts objectsForKey: @"name" notFoundMarker: nil]; } /* name lookup */ - (BOOL) isValidMailAccountName: (NSString *) _key { - NSArray *accounts; - - accounts = [[context activeUser] mailAccounts]; - - return [[accounts objectsForKey: @"name"] containsObject: _key]; + return [[self toManyRelationshipKeys] containsObject: _key]; } // - (id) mailAccountWithName: (NSString *) _key diff --git a/SoObjects/Mailer/SOGoMailObject+Draft.m b/SoObjects/Mailer/SOGoMailObject+Draft.m index b3eff781c..723f9ced2 100644 --- a/SoObjects/Mailer/SOGoMailObject+Draft.m +++ b/SoObjects/Mailer/SOGoMailObject+Draft.m @@ -101,7 +101,7 @@ if ([keys count]) { - types = [keys objectsForKey: @"mimeType"]; + types = [keys objectsForKey: @"mimeType" notFoundMarker: @""]; index = [types indexOfObject: @"text/plain"]; if (index == NSNotFound) { diff --git a/SoObjects/Mailer/SOGoMailObject.m b/SoObjects/Mailer/SOGoMailObject.m index e39a4d554..598fc38eb 100644 --- a/SoObjects/Mailer/SOGoMailObject.m +++ b/SoObjects/Mailer/SOGoMailObject.m @@ -604,10 +604,11 @@ static BOOL debugSoParts = NO; id result; [self debugWithFormat: @"fetch keys: %@", _fetchKeys]; - - result = [self fetchParts: [_fetchKeys objectsForKey: @"key"]]; + + result = [self fetchParts: [_fetchKeys objectsForKey: @"key" + notFoundMarker: nil]]; result = [result valueForKey: @"RawResponse"]; // hackish - + // Note: -valueForKey: doesn't work! result = [(NSDictionary *)result objectForKey: @"fetch"]; diff --git a/SoObjects/SOGo/NSArray+Utilities.h b/SoObjects/SOGo/NSArray+Utilities.h index 8f3cc836c..1f379d475 100644 --- a/SoObjects/SOGo/NSArray+Utilities.h +++ b/SoObjects/SOGo/NSArray+Utilities.h @@ -35,7 +35,8 @@ - (NSArray *) stringsWithFormat: (NSString *) format; - (NSArray *) keysWithFormat: (NSString *) format; -- (NSArray *) objectsForKey: (NSString *) key; +- (NSArray *) objectsForKey: (NSString *) key + notFoundMarker: (id) marker; - (NSArray *) flattenedArray; - (NSArray *) uniqueObjects; diff --git a/SoObjects/SOGo/NSArray+Utilities.m b/SoObjects/SOGo/NSArray+Utilities.m index 146ed07e0..5cbb720f0 100644 --- a/SoObjects/SOGo/NSArray+Utilities.m +++ b/SoObjects/SOGo/NSArray+Utilities.m @@ -85,6 +85,7 @@ } - (NSArray *) objectsForKey: (NSString *) key + notFoundMarker: (id) marker { NSMutableArray *objectsForKey; unsigned int count, max; @@ -96,7 +97,10 @@ for (count = 0; count < max; count++) { value = [[self objectAtIndex: count] objectForKey: key]; - [objectsForKey addObject: value]; + if (value) + [objectsForKey addObject: value]; + else if (marker) + [objectsForKey addObject: marker]; } return objectsForKey; diff --git a/SoObjects/SOGo/SOGoGCSFolder.m b/SoObjects/SOGo/SOGoGCSFolder.m index 43259a10f..80e2a8b5b 100644 --- a/SoObjects/SOGo/SOGoGCSFolder.m +++ b/SoObjects/SOGo/SOGoGCSFolder.m @@ -467,7 +467,7 @@ static NSArray *childRecordFields = nil; return records; [childRecords release]; - names = [records objectsForKey: @"c_name"]; + names = [records objectsForKey: @"c_name" notFoundMarker: nil]; childRecords = [[NSMutableDictionary alloc] initWithObjects: records forKeys: names]; diff --git a/SoObjects/SOGo/SOGoUser.m b/SoObjects/SOGo/SOGoUser.m index b35f87d1c..ec5e1a00f 100644 --- a/SoObjects/SOGo/SOGoUser.m +++ b/SoObjects/SOGo/SOGoUser.m @@ -751,8 +751,8 @@ _timeValue (NSString *key) { NSArray *identities; - [self mailAccounts]; - identities = [mailAccounts objectsForKey: @"identities"]; + identities = [[self mailAccounts] objectsForKey: @"identities" + notFoundMarker: nil]; return [identities flattenedArray]; } diff --git a/UI/MailerUI/UIxMailListView.m b/UI/MailerUI/UIxMailListView.m index 429062607..002f4332e 100644 --- a/UI/MailerUI/UIxMailListView.m +++ b/UI/MailerUI/UIxMailListView.m @@ -274,11 +274,11 @@ parts = [[message objectForKey: @"body"] objectForKey: @"parts"]; if ([parts count] > 1) { - dispositions - = [[parts objectsForKey: @"disposition"] objectEnumerator]; + dispositions = [[parts objectsForKey: @"disposition" + notFoundMarker: nil] objectEnumerator]; while (!hasAttachment && (currentDisp = [dispositions nextObject])) - hasAttachment = ([[currentDisp objectForKey: @"type"] length]); + hasAttachment = ([[currentDisp objectForKey: @"type"] length]); } return hasAttachment; diff --git a/UI/MailerUI/UIxMailMainFrame.m b/UI/MailerUI/UIxMailMainFrame.m index 84fbdf1f1..423d5d692 100644 --- a/UI/MailerUI/UIxMailMainFrame.m +++ b/UI/MailerUI/UIxMailMainFrame.m @@ -69,12 +69,14 @@ } /* accessors */ + +#warning this method is a duplication of SOGoMailAccounts:toManyRelationShipKeys - (NSString *) mailAccounts { NSArray *accounts, *accountNames; accounts = [[context activeUser] mailAccounts]; - accountNames = [accounts objectsForKey: @"name"]; + accountNames = [accounts objectsForKey: @"name" notFoundMarker: nil]; return [accountNames jsonRepresentation]; } @@ -183,7 +185,8 @@ // We use the first mail account accounts = [[context activeUser] mailAccounts]; - firstAccount = [[accounts objectsForKey: @"name"] objectAtIndex: 0]; + firstAccount = [[accounts objectsForKey: @"name" notFoundMarker: nil] + objectAtIndex: 0]; request = [context request]; if ((folderId = [request formValueForKey: @"folder"]) &&