Monotone-Parent: bdfc1c269ab737136bc8baf0281b23d80921f8b7

Monotone-Revision: 7c15766f188357a9b9016c2300c2a4a7d2b95404

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2006-09-19T21:03:12
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau 2006-09-19 21:03:12 +00:00
parent 8745c0ce33
commit 2e4d9d2d6d
2 changed files with 52 additions and 38 deletions

View file

@ -1,5 +1,9 @@
2006-09-19 Wolfgang Sourdeau <wsourdeau@inverse.ca> 2006-09-19 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* UI/Contacts/UIxContactEditor.m ([UIxContactEditor
-initSnapshot]): retrieve "contactEmail" and "contactFN" from the
query parameters and put their values (if any) into the snapshot.
* UI/Contacts/UIxContactView.m ([UIxContactView -note]): convert * UI/Contacts/UIxContactView.m ([UIxContactView -note]): convert
carriage-returns to "<br />". carriage-returns to "<br />".
([UIxContactView -workCompany]): explicitly initialize company to ([UIxContactView -workCompany]): explicitly initialize company to

View file

@ -30,44 +30,39 @@
@implementation UIxContactEditor @implementation UIxContactEditor
- (id)init { - (id) init
if ((self = [super init])) { {
self->snapshot = [[NSMutableDictionary alloc] initWithCapacity:16]; if ((self = [super init]))
preferredEmail = nil; {
} snapshot = [[NSMutableDictionary alloc] initWithCapacity:16];
preferredEmail = nil;
}
return self; return self;
} }
- (void)dealloc { - (void) dealloc
[self->snapshot release]; {
[self->errorText release]; [snapshot release];
[errorText release];
[super dealloc]; [super dealloc];
} }
/* accessors */ /* accessors */
- (NSMutableDictionary *) snapshot - (void) setErrorText: (NSString *) _txt
{ {
NSString *email; ASSIGNCOPY(errorText, _txt);
email = [self queryParameterForKey:@"contactEmail"];
if ([email length] > 0
&& ![[self->snapshot objectForKey: @"mail"] length])
[self->snapshot setObject: email forKey: @"mail"];
return self->snapshot;
} }
- (void)setErrorText:(NSString *)_txt { - (NSString *) errorText
ASSIGNCOPY(self->errorText, _txt); {
} return errorText;
- (NSString *)errorText {
return self->errorText;
} }
- (BOOL)hasErrorText { - (BOOL) hasErrorText
return [self->errorText length] > 0 ? YES : NO; {
return [errorText length] > 0 ? YES : NO;
} }
/* load/store content format */ /* load/store content format */
@ -76,9 +71,9 @@
// TODO: perform sanity checking, eg build CN on demand // TODO: perform sanity checking, eg build CN on demand
NSString *cn, *gn, *sn; NSString *cn, *gn, *sn;
cn = [self->snapshot objectForKey:@"cn"]; cn = [snapshot objectForKey:@"cn"];
gn = [self->snapshot objectForKey:@"givenName"]; gn = [snapshot objectForKey:@"givenName"];
sn = [self->snapshot objectForKey:@"sn"]; sn = [snapshot objectForKey:@"sn"];
if (![sn isNotNull] || [sn length] == 0) if (![sn isNotNull] || [sn length] == 0)
sn = nil; sn = nil;
@ -97,7 +92,7 @@
? [cn substringFromIndex:(r.location + r.length)] ? [cn substringFromIndex:(r.location + r.length)]
: cn; : cn;
} }
[self->snapshot setObject:sn forKey:@"sn"]; [snapshot setObject:sn forKey:@"sn"];
} }
if (sn == nil && gn == nil) if (sn == nil && gn == nil)
cn = @"[noname]"; cn = @"[noname]";
@ -107,7 +102,7 @@
cn = sn; cn = sn;
else else
cn = [[gn stringByAppendingString:@" "] stringByAppendingString:sn]; cn = [[gn stringByAppendingString:@" "] stringByAppendingString:sn];
[self->snapshot setObject:cn forKey:@"cn"]; [snapshot setObject:cn forKey:@"cn"];
} }
/* helper */ /* helper */
@ -152,6 +147,11 @@
[snapshot setObject: aValue forKey: key]; [snapshot setObject: aValue forKey: key];
} }
- (NSMutableDictionary *) snapshot
{
return snapshot;
}
- (NSString *) _simpleValueForType: (NSString *) aType - (NSString *) _simpleValueForType: (NSString *) aType
inArray: (NSArray *) anArray inArray: (NSArray *) anArray
{ {
@ -193,15 +193,10 @@
else else
workMail = potential; workMail = potential;
} }
if (!homeMail) if (!homeMail && max > 1)
{ {
if (workMail && max > 1) if (workMail && workMail == potential)
{ homeMail = [[elements objectAtIndex: 1] value: 0];
if (workMail == potential)
homeMail = [[elements objectAtIndex: 1] value: 0];
else
homeMail = potential;
}
else else
homeMail = potential; homeMail = potential;
} }
@ -250,6 +245,16 @@
preferredEmail = aString; preferredEmail = aString;
} }
- (void) _retrieveQueryParameter: (NSString *) queryKey
intoSnapshotValue: (NSString *) snapshotKey
{
NSString *queryValue;
queryValue = [self queryParameterForKey: queryKey];
if (queryValue && [queryValue length] > 0)
[self _setSnapshotValue: snapshotKey to: queryValue];
}
- (void) initSnapshot - (void) initSnapshot
{ {
NSArray *n, *elements; NSArray *n, *elements;
@ -322,6 +327,11 @@
[self _setSnapshotValue: @"bday" to: [card bday]]; [self _setSnapshotValue: @"bday" to: [card bday]];
[self _setSnapshotValue: @"tz" to: [card tz]]; [self _setSnapshotValue: @"tz" to: [card tz]];
[self _setSnapshotValue: @"note" to: [card note]]; [self _setSnapshotValue: @"note" to: [card note]];
[self _retrieveQueryParameter: @"contactEmail"
intoSnapshotValue: @"workMail"];
[self _retrieveQueryParameter: @"contactFN"
intoSnapshotValue: @"fn"];
} }
- (id <WOActionResults>) defaultAction - (id <WOActionResults>) defaultAction