diff --git a/ActiveSync/NGDOMElement+ActiveSync.m b/ActiveSync/NGDOMElement+ActiveSync.m index 1a44e8a95..e9294e573 100644 --- a/ActiveSync/NGDOMElement+ActiveSync.m +++ b/ActiveSync/NGDOMElement+ActiveSync.m @@ -101,7 +101,7 @@ static NSArray *asElementArray = nil; int i, count; if (!asElementArray) - asElementArray = [[NSArray alloc] initWithObjects: @"Attendee", nil]; + asElementArray = [[NSArray alloc] initWithObjects: @"Attendee", @"Category", nil]; data = [NSMutableDictionary dictionary]; @@ -153,7 +153,10 @@ static NSArray *asElementArray = nil; if ([innerTag isEqualToString: [innerElement tagName]]) { - [innerElements addObject: [(NGDOMElement *)innerElement applicationData]]; + if ([(id)innerElement isTextNode]) + [innerElements addObject: [(NGDOMElement *)innerElement textValue]]; + else + [innerElements addObject: [(NGDOMElement *)innerElement applicationData]]; } else { diff --git a/ActiveSync/NGVCard+ActiveSync.m b/ActiveSync/NGVCard+ActiveSync.m index d6f8fa199..9ac476969 100644 --- a/ActiveSync/NGVCard+ActiveSync.m +++ b/ActiveSync/NGVCard+ActiveSync.m @@ -47,9 +47,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - (NSString *) activeSyncRepresentationInContext: (WOContext *) context { + NSArray *emails, *addresses, *categories, *elements; CardElement *n, *homeAdr, *workAdr; - NSArray *emails, *addresses; NSMutableString *s; + NSString *url; id o; int i; @@ -65,10 +66,42 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. if ((o = [self workCompany])) [s appendFormat: @"%@", [o activeSyncRepresentationInContext: context]]; + + if ((o = [[self org] flattenedValueAtIndex: 1 forKey: @""])) + [s appendFormat: @"%@", [o activeSyncRepresentationInContext: context]]; + + categories = [self categories]; + + if ([categories count]) + { + [s appendFormat: @""]; + for (i = 0; i < [categories count]; i++) + { + [s appendFormat: @"%@", [[categories objectAtIndex: i] activeSyncRepresentationInContext: context]]; + } + [s appendFormat: @""]; + } + + elements = [self childrenWithTag: @"url" + andAttribute: @"type" + havingValue: @"work"]; + if ([elements count] > 0) + { + url = [[elements objectAtIndex: 0] flattenedValuesForKey: @""]; + [s appendFormat: @"%@", [url activeSyncRepresentationInContext: context]]; + } + + + if ((o = [[self uniqueChildWithTag: @"x-aim"] flattenedValuesForKey: @""])) + [s appendFormat: @"%@", [o activeSyncRepresentationInContext: context]]; + + if ((o = [self nickname])) + [s appendFormat: @"%@", [o activeSyncRepresentationInContext: context]]; + if ((o = [self title])) [s appendFormat: @"%@", [o activeSyncRepresentationInContext: context]]; - + if ((o = [self preferredEMail])) [s appendFormat: @"%@", o]; @@ -183,6 +216,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. if ((o = [[theValues objectForKey: @"Body"] objectForKey: @"Data"])) [self setNote: o]; + // Categories + if ((o = [theValues objectForKey: @"Categories"])) + [self setCategories: o]; + // Birthday if ((o = [theValues objectForKey: @"Birthday"])) { @@ -238,24 +275,31 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Company's name if ((o = [theValues objectForKey: @"CompanyName"])) - { - [self setOrg: o units: nil]; - } + [self setOrg: o units: nil]; + + // Department + if ((o = [theValues objectForKey: @"Department"])) + [self setOrg: nil units: [NSArray arrayWithObjects:o,nil]]; // Email addresses if ((o = [theValues objectForKey: @"Email1Address"])) { - [self addEmail: o types: [NSArray arrayWithObject: @"pref"]]; + element = [self elementWithTag: @"email" ofType: @"work"]; + [element setSingleValue: o forKey: @""]; } if ((o = [theValues objectForKey: @"Email2Address"])) { - [self addEmail: o types: nil]; + element = [self elementWithTag: @"email" ofType: @"home"]; + [element setSingleValue: o forKey: @""]; } + // SOGo currently only supports 2 email addresses ... but AS clients might send 3 + // FIXME: revise this when the GUI revamp is done in SOGo if ((o = [theValues objectForKey: @"Email3Address"])) { - [self addEmail: o types: nil]; + element = [self elementWithTag: @"email" ofType: @"three"]; + [element setSingleValue: o forKey: @""]; } // Formatted name @@ -293,16 +337,15 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Job's title if ((o = [theValues objectForKey: @"JobTitle"])) - { - [self setTitle: o]; - } + [self setTitle: o]; // WebPage (work) if ((o = [theValues objectForKey: @"WebPage"])) - { - [[self elementWithTag: @"url" ofType: @"work"] + [[self elementWithTag: @"url" ofType: @"work"] setSingleValue: o forKey: @""]; - } + + if ((o = [theValues objectForKey: @"NickName"])) + [self setNickname: o]; } @end