Skip to content

Commit

Permalink
Mapped lots of contact properties
Browse files Browse the repository at this point in the history
  • Loading branch information
extrafu committed Feb 6, 2014
1 parent 9311f05 commit 3175a91
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 50 deletions.
155 changes: 118 additions & 37 deletions ActiveSync/NGVCard+ActiveSync.m
Expand Up @@ -171,45 +171,126 @@ - (NSString *) activeSyncRepresentation
//
- (void) takeActiveSyncValues: (NSDictionary *) theValues
{
CardElement *element;
id o;

// Contact's note
if ((o = [[theValues objectForKey: @"Body"] objectForKey: @"Data"]))
[self setNote: o];

//
// Business address information
//
// BusinessStreet
// BusinessCity
// BusinessPostalCode
// BusinessState
// BusinessCountry
//
element = [self elementWithTag: @"adr" ofType: @"work"];
[element setSingleValue: @""
atIndex: 1 forKey: @""];
[element setSingleValue: [theValues objectForKey: @"BusinessStreet"]
atIndex: 2 forKey: @""];
[element setSingleValue: [theValues objectForKey: @"BusinessCity"]
atIndex: 3 forKey: @""];
[element setSingleValue: [theValues objectForKey: @"BusinessState"]
atIndex: 4 forKey: @""];
[element setSingleValue: [theValues objectForKey: @"BusinessPostalCode"]
atIndex: 5 forKey: @""];
[element setSingleValue: [theValues objectForKey: @"BusinessCountry"]
atIndex: 6 forKey: @""];

//
// Home address information
//
// HomeStreet
// HomeCity
// HomePostalCode
// HomeState
// HomeCountry
//
element = [self elementWithTag: @"adr" ofType: @"home"];
[element setSingleValue: @""
atIndex: 1 forKey: @""];
[element setSingleValue: [theValues objectForKey: @"HomeStreet"]
atIndex: 2 forKey: @""];
[element setSingleValue: [theValues objectForKey: @"HomeCity"]
atIndex: 3 forKey: @""];
[element setSingleValue: [theValues objectForKey: @"HomeState"]
atIndex: 4 forKey: @""];
[element setSingleValue: [theValues objectForKey: @"HomePostalCode"]
atIndex: 5 forKey: @""];
[element setSingleValue: [theValues objectForKey: @"HomeCountry"]
atIndex: 6 forKey: @""];

// Company's name
if ((o = [theValues objectForKey: @"CompanyName"]))
{
[self setOrg: o units: nil];
}

// Email addresses
if ((o = [theValues objectForKey: @"Email1Address"]))
{
[self addEmail: o types: [NSArray arrayWithObject: @"pref"]];
}

if ((o = [theValues objectForKey: @"Email2Address"]))
{
[self addEmail: o types: nil];
}

if ((o = [theValues objectForKey: @"Email3Address"]))
{
[self addEmail: o types: nil];
}

// Formatted name
// MiddleName
// Suffix (II)
// Title (Mr.)
[self setFn: [theValues objectForKey: @"FileAs"]];

[self setNWithFamily: [theValues objectForKey: @"LastName"]
given: [theValues objectForKey: @"FirstName"]
additional: nil prefixes: nil suffixes: nil];

// IM information
[[self uniqueChildWithTag: @"x-aim"]
setSingleValue: [theValues objectForKey: @"IMAddress"]
forKey: @""];

//
// Phone numbrrs
//
element = [self elementWithTag: @"tel" ofType: @"work"];
[element setSingleValue: [theValues objectForKey: @"BusinessPhoneNumber"] forKey: @""];

element = [self elementWithTag: @"tel" ofType: @"home"];
[element setSingleValue: [theValues objectForKey: @"HomePhoneNumber"] forKey: @""];

element = [self elementWithTag: @"tel" ofType: @"cell"];
[element setSingleValue: [theValues objectForKey: @"MobilePhoneNumber"] forKey: @""];

if ((o = [theValues objectForKey: @"CompanyName"]))
{
[self setOrg: o units: nil];
}

if ((o = [theValues objectForKey: @"Email1Address"]))
{
[self addEmail: o types: [NSArray arrayWithObject: @"pref"]];
}

if ((o = [theValues objectForKey: @"Email2Address"]))
{
[self addEmail: o types: nil];
}

if ((o = [theValues objectForKey: @"Email3Address"]))
{
[self addEmail: o types: nil];
}

[self setNWithFamily: [theValues objectForKey: @"LastName"]
given: [theValues objectForKey: @"FirstName"]
additional: nil prefixes: nil suffixes: nil];

if ((o = [theValues objectForKey: @"MobilePhoneNumber"]))
{
}

if ((o = [theValues objectForKey: @"Title"]))
{
[self setTitle: o];
}

if ((o = [theValues objectForKey: @"WebPage"]))
{
}

element = [self elementWithTag: @"tel" ofType: @"fax"];
[element setSingleValue: [theValues objectForKey: @"BusinessFaxNumber"] forKey: @""];

element = [self elementWithTag: @"tel" ofType: @"pager"];
[element setSingleValue: [theValues objectForKey: @"PagerNumber"] forKey: @""];

// Job's title
if ((o = [theValues objectForKey: @"JobTitle"]))
{
[self setTitle: o];
}

// WebPage (work)
if ((o = [theValues objectForKey: @"WebPage"]))
{
[[self elementWithTag: @"url" ofType: @"work"]
setSingleValue: o forKey: @""];
}
}

@end
3 changes: 3 additions & 0 deletions SoObjects/Contacts/NGVCard+SOGo.h
Expand Up @@ -28,6 +28,9 @@

@interface NGVCard (SOGoExtensions)

- (CardElement *) elementWithTag: (NSString *) elementTag
ofType: (NSString *) type;

- (void) updateFromLDIFRecord: (NSDictionary *) ldifRecord;
- (NSMutableDictionary *) asLDIFRecord;

Expand Down
26 changes: 13 additions & 13 deletions SoObjects/Contacts/NGVCard+SOGo.m
Expand Up @@ -164,8 +164,8 @@ test contact (export from tb):
@implementation NGVCard (SOGoExtensions)

/* LDIF -> VCARD */
- (CardElement *) _elementWithTag: (NSString *) elementTag
ofType: (NSString *) type
- (CardElement *) elementWithTag: (NSString *) elementTag
ofType: (NSString *) type
{
NSArray *elements;
CardElement *element;
Expand All @@ -188,26 +188,26 @@ - (void) _setPhoneValues: (NSDictionary *) ldifRecord
{
CardElement *phone;

phone = [self _elementWithTag: @"tel" ofType: @"work"];
phone = [self elementWithTag: @"tel" ofType: @"work"];
[phone setSingleValue: [ldifRecord objectForKey: @"telephonenumber"] forKey: @""];
phone = [self _elementWithTag: @"tel" ofType: @"home"];
phone = [self elementWithTag: @"tel" ofType: @"home"];
[phone setSingleValue: [ldifRecord objectForKey: @"homephone"] forKey: @""];
phone = [self _elementWithTag: @"tel" ofType: @"cell"];
phone = [self elementWithTag: @"tel" ofType: @"cell"];
[phone setSingleValue: [ldifRecord objectForKey: @"mobile"] forKey: @""];
phone = [self _elementWithTag: @"tel" ofType: @"fax"];
phone = [self elementWithTag: @"tel" ofType: @"fax"];
[phone setSingleValue: [ldifRecord objectForKey: @"facsimiletelephonenumber"]
forKey: @""];
phone = [self _elementWithTag: @"tel" ofType: @"pager"];
phone = [self elementWithTag: @"tel" ofType: @"pager"];
[phone setSingleValue: [ldifRecord objectForKey: @"pager"] forKey: @""];
}

- (void) _setEmails: (NSDictionary *) ldifRecord
{
CardElement *mail, *homeMail;

mail = [self _elementWithTag: @"email" ofType: @"work"];
mail = [self elementWithTag: @"email" ofType: @"work"];
[mail setSingleValue: [ldifRecord objectForKey: @"mail"] forKey: @""];
homeMail = [self _elementWithTag: @"email" ofType: @"home"];
homeMail = [self elementWithTag: @"email" ofType: @"home"];
[homeMail setSingleValue: [ldifRecord objectForKey: @"mozillasecondemail"] forKey: @""];
[[self uniqueChildWithTag: @"x-mozilla-html"]
setSingleValue: [ldifRecord objectForKey: @"mozillausehtmlmail"]
Expand All @@ -230,7 +230,7 @@ - (void) updateFromLDIFRecord: (NSDictionary *) ldifRecord
[self setFn: [ldifRecord objectForKey: @"displayname"]];
[self setTitle: [ldifRecord objectForKey: @"title"]];

element = [self _elementWithTag: @"adr" ofType: @"home"];
element = [self elementWithTag: @"adr" ofType: @"home"];
[element setSingleValue: [ldifRecord objectForKey: @"mozillahomestreet2"]
atIndex: 1 forKey: @""];
[element setSingleValue: [ldifRecord objectForKey: @"mozillahomestreet"]
Expand All @@ -244,7 +244,7 @@ - (void) updateFromLDIFRecord: (NSDictionary *) ldifRecord
[element setSingleValue: [ldifRecord objectForKey: @"mozillahomecountryname"]
atIndex: 6 forKey: @""];

element = [self _elementWithTag: @"adr" ofType: @"work"];
element = [self elementWithTag: @"adr" ofType: @"work"];
[element setSingleValue: [ldifRecord objectForKey: @"mozillaworkstreet2"]
atIndex: 1 forKey: @""];
[element setSingleValue: [ldifRecord objectForKey: @"street"]
Expand All @@ -268,9 +268,9 @@ - (void) updateFromLDIFRecord: (NSDictionary *) ldifRecord

[self _setPhoneValues: ldifRecord];
[self _setEmails: ldifRecord];
[[self _elementWithTag: @"url" ofType: @"home"]
[[self elementWithTag: @"url" ofType: @"home"]
setSingleValue: [ldifRecord objectForKey: @"mozillahomeurl"] forKey: @""];
[[self _elementWithTag: @"url" ofType: @"work"]
[[self elementWithTag: @"url" ofType: @"work"]
setSingleValue: [ldifRecord objectForKey: @"mozillaworkurl"] forKey: @""];

[[self uniqueChildWithTag: @"x-aim"]
Expand Down

0 comments on commit 3175a91

Please sign in to comment.