From 0b5ea38d2ca3f6bb08b562e3c4267ef1cc8628af Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 21 Dec 2007 21:49:05 +0000 Subject: [PATCH] Monotone-Parent: 40a0028366ecf340e0202b4e2bc2c314cb602e80 Monotone-Revision: 2918fd48475c28fab3fffda506a3e755d3121d38 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-12-21T21:49:05 Monotone-Branch: ca.inverse.sogo --- UI/Contacts/UIxContactEditor.m | 61 ++++++++++++---------------------- 1 file changed, 22 insertions(+), 39 deletions(-) diff --git a/UI/Contacts/UIxContactEditor.m b/UI/Contacts/UIxContactEditor.m index 7181f47a6..754b6ea78 100644 --- a/UI/Contacts/UIxContactEditor.m +++ b/UI/Contacts/UIxContactEditor.m @@ -50,7 +50,7 @@ - (void) dealloc { - [snapshot release]; + [snapshot release]; [preferredEmail release]; [super dealloc]; } @@ -88,44 +88,26 @@ /* load/store content format */ -- (void) _fixupSnapshot -{ - // TODO: perform sanity checking, eg build CN on demand - NSString *cn, *gn, *sn; - - cn = [snapshot objectForKey: @"cn"]; - gn = [snapshot objectForKey: @"givenName"]; - sn = [snapshot objectForKey: @"sn"]; - - if (![sn isNotNull] || [sn length] == 0) - sn = nil; - if (![cn isNotNull] || [cn length] == 0) - cn = nil; - - if (sn == nil) { - if (cn == nil) - sn = @"[noname]"; - else { - // TODO: need a better name parser here - NSRange r; - - r = [cn rangeOfString: @" "]; - sn = (r.length > 0) - ? [cn substringFromIndex:(r.location + r.length)] - : cn; - } - [snapshot setObject:sn forKey: @"sn"]; - } - if (sn == nil && gn == nil) - cn = @"[noname]"; - else if (sn == nil) - cn = gn; - else if (gn == nil) - cn = sn; - else - cn = [[gn stringByAppendingString: @" "] stringByAppendingString:sn]; - [snapshot setObject:cn forKey: @"cn"]; -} +// - (void) _fixupSnapshot +// { +// NSString *currentKey, *currentString; +// NSMutableString *newString; +// NSArray *keys; +// unsigned int count, max; + +// keys = [snapshot allKeys]; +// max = [keys count]; +// for (count = 0; count < max; count++) +// { +// currentKey = [keys objectAtIndex: count]; +// currentString = [snapshot objectForKey: currentKey]; +// newString = [currentString mutableCopy]; +// [newString autorelease]; +// [newString replaceString: @";" withString: @"\\;"]; +// if (![newString isEqualToString: currentString]) +// [snapshot setObject: newString forKey: currentKey]; +// } +// } /* helper */ @@ -518,6 +500,7 @@ card = [contact vCard]; if (card) { +// [self _fixupSnapshot]; [self _saveSnapshot]; [contact save];