Monotone-Parent: f844c722fbaf58bf1e6166c82175c6ca3aca9074

Monotone-Revision: f463d17bed09b78de002a4dfc873a1f45b6aa7b7

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2007-03-22T19:02:45
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau 2007-03-22 19:02:45 +00:00
parent 3abf38778d
commit 520249ebb7
3 changed files with 88 additions and 23 deletions

View file

@ -31,8 +31,8 @@
@interface UIxContactEditor : UIxComponent @interface UIxContactEditor : UIxComponent
{ {
NSString *errorText;
NSString *preferredEmail; NSString *preferredEmail;
NSString *item;
NGVCard *card; NGVCard *card;
NSMutableDictionary *snapshot; /* contains the values for editing */ NSMutableDictionary *snapshot; /* contains the values for editing */
} }

View file

@ -46,25 +46,39 @@
- (void) dealloc - (void) dealloc
{ {
[snapshot release]; [snapshot release];
[errorText release]; [preferredEmail release];
[super dealloc]; [super dealloc];
} }
/* accessors */ /* accessors */
- (void) setErrorText: (NSString *) _txt - (NSArray *) htmlMailFormatList
{ {
ASSIGNCOPY(errorText, _txt); static NSArray *htmlMailFormatItems = nil;
if (!htmlMailFormatItems)
{
htmlMailFormatItems = [NSArray arrayWithObjects: @"FALSE", @"TRUE", nil];
[htmlMailFormatItems retain];
}
return htmlMailFormatItems;
} }
- (NSString *) errorText - (NSString *) itemHtmlMailFormatText
{ {
return errorText; return [self labelForKey:
[NSString stringWithFormat: @"htmlMailFormat_%@", item]];
} }
- (BOOL) hasErrorText - (void) setItem: (NSString *) newItem
{ {
return [errorText length] > 0 ? YES : NO; item = newItem;
}
- (NSString *) item
{
return item;
} }
/* load/store content format */ /* load/store content format */
@ -214,6 +228,9 @@
[self _setSnapshotValue: @"workMail" to: workMail]; [self _setSnapshotValue: @"workMail" to: workMail];
[self _setSnapshotValue: @"homeMail" to: homeMail]; [self _setSnapshotValue: @"homeMail" to: homeMail];
[self _setSnapshotValue: @"mozillaUseHtmlMail"
to: [[card uniqueChildWithTag: @"x-mozilla-html"] value: 0]];
} }
- (void) _setupOrgFields - (void) _setupOrgFields
@ -291,6 +308,9 @@
[self _setupEmailFields]; [self _setupEmailFields];
[self _setSnapshotValue: @"screenName"
to: [[card uniqueChildWithTag: @"x-aim"] value: 0]];
elements = [card childrenWithTag: @"adr" elements = [card childrenWithTag: @"adr"
andAttribute: @"type" havingValue: @"work"]; andAttribute: @"type" havingValue: @"work"];
if (elements && [elements count] > 0) if (elements && [elements count] > 0)
@ -425,6 +445,10 @@
else else
[card setPreferred: homeMail]; [card setPreferred: homeMail];
} }
[[card uniqueChildWithTag: @"x-mozilla-html"]
setValue: 0
to: [snapshot objectForKey: @"mozillaUseHtmlMail"]];
} }
- (void) _saveSnapshot - (void) _saveSnapshot
@ -463,6 +487,8 @@
[self _savePhoneValues]; [self _savePhoneValues];
[self _saveEmails]; [self _saveEmails];
[[card uniqueChildWithTag: @"x-aim"]
setValue: 0 to: [snapshot objectForKey: @"screenName"]];
} }
- (id <WOActionResults>) saveAction - (id <WOActionResults>) saveAction

View file

@ -55,7 +55,7 @@
if (value && [value length] > 0) if (value && [value length] > 0)
{ {
if (label) if (label)
[cardString appendFormat: @"%@%@<br />\n", [cardString appendFormat: @"%@&nbsp;%@<br />\n",
[self labelForKey: label], value]; [self labelForKey: label], value];
else else
[cardString appendFormat: @"%@<br />\n", value]; [cardString appendFormat: @"%@<br />\n", value];
@ -73,35 +73,74 @@
- (NSString *) displayName - (NSString *) displayName
{ {
return [self _cardStringWithLabel: @"Display Name: " return [self _cardStringWithLabel: @"Display Name:"
value: [card fn]]; value: [card fn]];
} }
- (NSString *) nickName - (NSString *) nickName
{ {
return [self _cardStringWithLabel: @"Nickname: " return [self _cardStringWithLabel: @"Nickname:"
value: [card nickname]]; value: [card nickname]];
} }
- (NSString *) preferredEmail - (NSString *) primaryEmail
{ {
NSString *email, *mailTo; NSString *email, *mailTo;
email = [card preferredEMail]; email = [card preferredEMail];
if (email && [email length] > 0) if ([email length] > 0)
mailTo = [NSString stringWithFormat: @"<a href=\"mailto:%@\"" mailTo = [NSString stringWithFormat: @"<a href=\"mailto:%@\""
@" onclick=\"return onContactMailTo(this);\">" @" onclick=\"return onContactMailTo(this);\">"
@"%@</a>", email, email]; @"%@</a>", email, email];
else else
mailTo = nil; mailTo = nil;
return [self _cardStringWithLabel: @"Email Address: " return [self _cardStringWithLabel: @"Email:"
value: mailTo]; value: mailTo];
} }
- (NSString *) secondaryEmail
{
NSString *email, *mailTo;
NSMutableArray *emails;
emails = [NSMutableArray new];
[emails addObjectsFromArray: [card childrenWithTag: @"email"]];
[emails removeObjectsInArray: [card childrenWithTag: @"email"
andAttribute: @"type"
havingValue: @"pref"]];
if ([emails count] > 1)
{
email = [[emails objectAtIndex: 0] value: 0];
mailTo = [NSString stringWithFormat: @"<a href=\"mailto:%@\""
@" onclick=\"return onContactMailTo(this);\">"
@"%@</a>", email, email];
}
else
mailTo = nil;
return [self _cardStringWithLabel: @"Additional Email:"
value: mailTo];
}
- (NSString *) screenName
{
NSString *screenName, *goim;
screenName = [[card uniqueChildWithTag: @"x-aim"] value: 0];
if ([screenName length] > 0)
goim = [NSString stringWithFormat: @"<a href=\"aim:goim?screenname=%@\""
@">%@</a>", screenName, screenName];
else
goim = nil;
return [self _cardStringWithLabel: @"Screen Name:" value: goim];
}
- (NSString *) preferredTel - (NSString *) preferredTel
{ {
return [self _cardStringWithLabel: @"Phone Number: " return [self _cardStringWithLabel: @"Phone Number:"
value: [card preferredTel]]; value: [card preferredTel]];
} }
@ -137,27 +176,27 @@
- (NSString *) workPhone - (NSString *) workPhone
{ {
return [self _phoneOfType: @"work" withLabel: @"Work: "]; return [self _phoneOfType: @"work" withLabel: @"Work:"];
} }
- (NSString *) homePhone - (NSString *) homePhone
{ {
return [self _phoneOfType: @"home" withLabel: @"Home: "]; return [self _phoneOfType: @"home" withLabel: @"Home:"];
} }
- (NSString *) fax - (NSString *) fax
{ {
return [self _phoneOfType: @"fax" withLabel: @"Fax: "]; return [self _phoneOfType: @"fax" withLabel: @"Fax:"];
} }
- (NSString *) mobile - (NSString *) mobile
{ {
return [self _phoneOfType: @"cell" withLabel: @"Mobile: "]; return [self _phoneOfType: @"cell" withLabel: @"Mobile:"];
} }
- (NSString *) pager - (NSString *) pager
{ {
return [self _phoneOfType: @"pager" withLabel: @"Pager: "]; return [self _phoneOfType: @"pager" withLabel: @"Pager:"];
} }
- (BOOL) hasHomeInfos - (BOOL) hasHomeInfos
@ -383,12 +422,12 @@
- (NSString *) bday - (NSString *) bday
{ {
return [self _cardStringWithLabel: @"Birthday: " value: [card bday]]; return [self _cardStringWithLabel: @"Birthday:" value: [card bday]];
} }
- (NSString *) tz - (NSString *) tz
{ {
return [self _cardStringWithLabel: @"Timezone: " value: [card tz]]; return [self _cardStringWithLabel: @"Timezone:" value: [card tz]];
} }
- (NSString *) note - (NSString *) note
@ -404,7 +443,7 @@
withString: @"<br />"]; withString: @"<br />"];
} }
return [self _cardStringWithLabel: @"Note: " value: note]; return [self _cardStringWithLabel: @"Note:" value: note];
} }
/* hrefs */ /* hrefs */