Monotone-Parent: 40a0028366ecf340e0202b4e2bc2c314cb602e80

Monotone-Revision: 2918fd48475c28fab3fffda506a3e755d3121d38

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2007-12-21T21:49:05
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2007-12-21 21:49:05 +00:00
parent f2e40a1e56
commit 0b5ea38d2c

View File

@@ -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];