2010-11-18 23:33:44 +01:00
|
|
|
/* SOGoContactGCSEntry+MAPIStore.m - this file is part of SOGo
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Inverse inc.
|
|
|
|
*
|
|
|
|
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
|
|
|
*
|
|
|
|
* This file is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This file is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2011-01-11 18:18:11 +01:00
|
|
|
#import <Foundation/NSArray.h>
|
2010-11-18 23:33:44 +01:00
|
|
|
#import <Foundation/NSDictionary.h>
|
|
|
|
#import <Foundation/NSString.h>
|
|
|
|
#import <Foundation/NSValue.h>
|
|
|
|
|
|
|
|
#import <NGExtensions/NSObject+Logs.h>
|
|
|
|
#import <NGCards/NGVCard.h>
|
|
|
|
|
2011-01-06 04:18:38 +01:00
|
|
|
#include <mapistore/mapistore_nameid.h>
|
|
|
|
|
2010-11-19 21:58:20 +01:00
|
|
|
#import "MAPIStoreTypes.h"
|
2010-11-18 23:33:44 +01:00
|
|
|
|
2010-11-19 21:58:20 +01:00
|
|
|
#import "SOGoContactGCSEntry+MAPIStore.h"
|
2010-11-18 23:33:44 +01:00
|
|
|
|
|
|
|
@implementation SOGoContactGCSEntry (MAPIStoreMessage)
|
|
|
|
|
|
|
|
- (void) setMAPIProperties: (NSDictionary *) properties
|
|
|
|
{
|
|
|
|
NGVCard *newCard, *oldCard;
|
2011-01-11 18:18:11 +01:00
|
|
|
NSArray *addresses;
|
|
|
|
CardElement *adr;
|
2010-11-18 23:33:44 +01:00
|
|
|
id value;
|
|
|
|
|
|
|
|
[self logWithFormat: @"setMAPIProperties: %@", properties];
|
|
|
|
|
|
|
|
oldCard = [self vCard];
|
|
|
|
if (isNew)
|
|
|
|
newCard = oldCard;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
newCard = [NGVCard new];
|
|
|
|
[newCard setUid: [oldCard uid]];
|
|
|
|
ASSIGN (card, newCard);
|
|
|
|
[newCard release];
|
|
|
|
}
|
|
|
|
[newCard setTag: @"vcard"];
|
|
|
|
[newCard setVersion: @"3.0"];
|
|
|
|
[newCard setProdID: @"-//Inverse inc.//OpenChange+SOGo//EN"];
|
|
|
|
[newCard setProfile: @"vCard"];
|
|
|
|
|
|
|
|
value = [properties
|
2010-12-13 17:53:32 +01:00
|
|
|
objectForKey: MAPIPropertyKey (PR_DISPLAY_NAME_UNICODE)];
|
2010-11-18 23:33:44 +01:00
|
|
|
if (value)
|
|
|
|
[newCard setFn: value];
|
|
|
|
|
2011-01-06 04:18:38 +01:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PidLidEmail1EmailAddress)];
|
2010-11-18 23:33:44 +01:00
|
|
|
if (value)
|
|
|
|
[newCard addEmail: value types: nil];
|
|
|
|
|
2011-01-11 18:18:11 +01:00
|
|
|
/* Work address */
|
|
|
|
addresses = [newCard childrenWithTag: @"adr"
|
|
|
|
andAttribute: @"type"
|
|
|
|
havingValue: @"work"];
|
|
|
|
if ([addresses count] > 0)
|
|
|
|
{
|
|
|
|
adr = [addresses objectAtIndex: 0];
|
|
|
|
[adr setValues: nil];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
adr = [CardElement elementWithTag: @"adr"];
|
|
|
|
[adr addAttribute: @"type" value: @"work"];
|
|
|
|
[card addChild: adr];
|
|
|
|
}
|
|
|
|
|
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PidLidWorkAddressPostOfficeBox)];
|
|
|
|
if (value)
|
|
|
|
[adr setValue: 0 to: value];
|
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PidLidWorkAddressStreet)];
|
|
|
|
if (value)
|
|
|
|
[adr setValue: 2 to: value];
|
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PidLidWorkAddressCity)];
|
|
|
|
if (value)
|
|
|
|
[adr setValue: 3 to: value];
|
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PidLidWorkAddressState)];
|
|
|
|
if (value)
|
|
|
|
[adr setValue: 4 to: value];
|
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PidLidWorkAddressPostalCode)];
|
|
|
|
if (value)
|
|
|
|
[adr setValue: 5 to: value];
|
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PidLidWorkAddressCountry)];
|
|
|
|
if (value)
|
|
|
|
[adr setValue: 6 to: value];
|
|
|
|
|
2010-11-22 22:32:11 +01:00
|
|
|
ASSIGN (content, [newCard versitString]);
|
2010-11-18 23:33:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|