2011-02-24 21:30:01 +01:00
|
|
|
/* MAPIStoreContactsMessage.m - this file is part of SOGo
|
|
|
|
*
|
|
|
|
* Copyright (C) 2011 Inverse inc
|
|
|
|
*
|
|
|
|
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
2011-09-14 20:33:44 +02:00
|
|
|
* Ludovic Marcotte <lmarcotte@inverse.ca>
|
2011-02-24 21:30:01 +01:00
|
|
|
*
|
|
|
|
* 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
|
2011-08-12 17:02:01 +02:00
|
|
|
* the Free Software Foundation; either version 3, or (at your option)
|
2011-02-24 21:30:01 +01:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#import <Foundation/NSArray.h>
|
2011-05-30 23:12:56 +02:00
|
|
|
#import <Foundation/NSCalendarDate.h>
|
2011-02-24 21:30:01 +01:00
|
|
|
#import <Foundation/NSDictionary.h>
|
|
|
|
#import <Foundation/NSString.h>
|
2011-10-24 22:47:55 +02:00
|
|
|
#import <NGExtensions/NGBase64Coding.h>
|
2011-02-24 21:30:01 +01:00
|
|
|
#import <NGExtensions/NSObject+Logs.h>
|
2011-10-24 22:47:55 +02:00
|
|
|
#import <NGCards/NGVCard.h>
|
|
|
|
#import <NGCards/NGVCardPhoto.h>
|
2011-11-09 21:10:31 +01:00
|
|
|
#import <NGCards/NSArray+NGCards.h>
|
|
|
|
#import <NGCards/NSString+NGCards.h>
|
2011-02-24 21:30:01 +01:00
|
|
|
#import <Contacts/SOGoContactGCSEntry.h>
|
2011-11-09 21:10:31 +01:00
|
|
|
#import <Mailer/NSString+Mail.h>
|
2011-12-01 22:13:09 +01:00
|
|
|
#import <SOGo/SOGoPermissions.h>
|
2011-02-24 21:30:01 +01:00
|
|
|
|
2011-10-24 22:47:55 +02:00
|
|
|
#import "MAPIStoreContactsAttachment.h"
|
2011-08-12 20:41:25 +02:00
|
|
|
#import "MAPIStoreContactsFolder.h"
|
2011-04-13 21:59:04 +02:00
|
|
|
#import "MAPIStorePropertySelectors.h"
|
2011-02-24 21:30:01 +01:00
|
|
|
#import "MAPIStoreTypes.h"
|
|
|
|
#import "NSArray+MAPIStore.h"
|
2011-05-30 23:12:56 +02:00
|
|
|
#import "NSDate+MAPIStore.h"
|
2011-02-24 21:30:01 +01:00
|
|
|
#import "NSData+MAPIStore.h"
|
2011-07-20 20:28:37 +02:00
|
|
|
#import "NSObject+MAPIStore.h"
|
2011-02-24 21:30:01 +01:00
|
|
|
#import "NSString+MAPIStore.h"
|
|
|
|
|
|
|
|
#import "MAPIStoreContactsMessage.h"
|
|
|
|
|
|
|
|
#undef DEBUG
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <gen_ndr/exchange.h>
|
|
|
|
#include <mapistore/mapistore.h>
|
2011-03-07 20:15:16 +01:00
|
|
|
#include <mapistore/mapistore_errors.h>
|
2011-02-24 21:30:01 +01:00
|
|
|
#include <mapistore/mapistore_nameid.h>
|
|
|
|
|
2011-09-23 17:36:49 +02:00
|
|
|
@implementation SOGoContactGCSEntry (MAPIStoreExtension)
|
|
|
|
|
|
|
|
- (Class) mapistoreMessageClass
|
|
|
|
{
|
|
|
|
return [MAPIStoreContactsMessage class];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2011-02-24 21:30:01 +01:00
|
|
|
@implementation MAPIStoreContactsMessage
|
|
|
|
|
2011-10-24 22:47:55 +02:00
|
|
|
- (id) init
|
|
|
|
{
|
|
|
|
if ((self = [super init]))
|
|
|
|
{
|
|
|
|
fetchedAttachments = NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2011-09-14 20:33:44 +02:00
|
|
|
// TODO: this should be combined with the version found
|
|
|
|
// in UIxContactEditor.m
|
|
|
|
- (CardElement *) _elementWithTag: (NSString *) tag
|
|
|
|
ofType: (NSString *) type
|
|
|
|
forCard: (NGVCard *) card
|
|
|
|
{
|
|
|
|
NSArray *elements;
|
|
|
|
CardElement *element;
|
|
|
|
|
|
|
|
elements = [card childrenWithTag: tag
|
2012-03-02 21:44:24 +01:00
|
|
|
andAttribute: @"type" havingValue: type];
|
2011-09-14 20:33:44 +02:00
|
|
|
if ([elements count] > 0)
|
|
|
|
element = [elements objectAtIndex: 0];
|
|
|
|
else
|
|
|
|
{
|
|
|
|
element = [CardElement new];
|
|
|
|
[element autorelease];
|
|
|
|
[element setTag: tag];
|
|
|
|
[element addType: type];
|
|
|
|
[card addChild: element];
|
|
|
|
}
|
|
|
|
|
|
|
|
return element;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagIconIndex: (void **) data // TODO
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
/* see http://msdn.microsoft.com/en-us/library/cc815472.aspx */
|
|
|
|
*data = MAPILongValue (memCtx, 0x00000200);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagMessageClass: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
*data = talloc_strdup (memCtx, "IPM.Contact");
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
// - (int) getPidTagOfflineAddressBookName: (void **) data
|
2011-07-28 00:01:16 +02:00
|
|
|
// inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
// {
|
|
|
|
// *data = talloc_strdup (memCtx, "PR_OAB_NAME_UNICODE");
|
|
|
|
|
|
|
|
// return MAPISTORE_SUCCESS;
|
|
|
|
// }
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
// - (int) getPidTagOfflineAddressBookLanguageId: (void **) data
|
2011-07-28 00:01:16 +02:00
|
|
|
// inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
// {
|
|
|
|
// /* see http://msdn.microsoft.com/en-us/goglobal/bb895996.asxp */
|
|
|
|
// /* English US */
|
|
|
|
// *data = MAPILongValue (memCtx, 0x0409);
|
|
|
|
|
|
|
|
// return MAPISTORE_SUCCESS;
|
|
|
|
// }
|
2011-04-13 21:59:04 +02:00
|
|
|
|
2011-09-23 03:00:28 +02:00
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagTitle: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
NSString *stringValue;
|
|
|
|
|
|
|
|
stringValue = [[sogoObject vCard] title];
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagCompanyName: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-11-14 04:26:50 +01:00
|
|
|
CardElement *org;
|
2011-04-13 21:59:04 +02:00
|
|
|
|
2011-11-14 04:26:50 +01:00
|
|
|
org = [[sogoObject vCard] org];
|
|
|
|
*data = [[org flattenedValueAtIndex: 0 forKey: @""]
|
|
|
|
asUnicodeInMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagDepartmentName: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-11-14 04:26:50 +01:00
|
|
|
CardElement *org;
|
2011-04-13 21:59:04 +02:00
|
|
|
|
2011-11-14 04:26:50 +01:00
|
|
|
org = [[sogoObject vCard] org];
|
|
|
|
*data = [[org flattenedValueAtIndex: 1 forKey: @""]
|
|
|
|
asUnicodeInMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSendInternetEncoding: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
*data = MAPILongValue (memCtx, 0x00065001);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSubject: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [self getPidTagDisplayName: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidFileUnder: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [self getPidTagDisplayName: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidFileUnderId: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
*data = MAPILongValue (memCtx, 0xffffffff);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidEmail1DisplayName: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
NGVCard *vCard;
|
|
|
|
NSString *fn, *email;
|
|
|
|
|
|
|
|
vCard = [sogoObject vCard];
|
|
|
|
fn = [vCard fn];
|
|
|
|
email = [vCard preferredEMail];
|
|
|
|
*data = [[NSString stringWithFormat: @"%@ <%@>", fn, email]
|
|
|
|
asUnicodeInMemCtx: memCtx];
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidEmail1OriginalDisplayName: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
return [self getPidLidEmail1DisplayName: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidEmail1EmailAddress: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
NSString *stringValue;
|
|
|
|
|
|
|
|
stringValue = [[sogoObject vCard] preferredEMail];
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagAccount: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
return [self getPidLidEmail1EmailAddress: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagContactEmailAddresses: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
NSString *stringValue;
|
|
|
|
|
|
|
|
stringValue = [[sogoObject vCard] preferredEMail];
|
|
|
|
if (!stringValue)
|
|
|
|
stringValue = @"";
|
|
|
|
*data = [[NSArray arrayWithObject: stringValue]
|
2011-11-22 20:43:14 +01:00
|
|
|
asMVUnicodeInMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagEmsAbTargetAddress: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
NSString *stringValue;
|
|
|
|
|
|
|
|
stringValue = [[sogoObject vCard] preferredEMail];
|
|
|
|
*data = [[NSString stringWithFormat: @"SMTP:%@", stringValue]
|
|
|
|
asUnicodeInMemCtx: memCtx];
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSearchKey: (void **) data // TODO
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
NSString *stringValue;
|
|
|
|
|
|
|
|
stringValue = [[sogoObject vCard] preferredEMail];
|
|
|
|
*data = [[stringValue dataUsingEncoding: NSASCIIStringEncoding]
|
|
|
|
asBinaryInMemCtx: memCtx];
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagMailPermission: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
return [self getYes: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidEmail2EmailAddress: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
NSMutableArray *emails;
|
|
|
|
NSString *email, *stringValue;
|
|
|
|
NGVCard *card;
|
|
|
|
NSUInteger count, max;
|
|
|
|
|
|
|
|
emails = [NSMutableArray array];
|
|
|
|
stringValue = nil;
|
|
|
|
|
|
|
|
card = [sogoObject vCard];
|
|
|
|
[emails addObjectsFromArray: [card childrenWithTag: @"email"]];
|
|
|
|
[emails removeObjectsInArray: [card childrenWithTag: @"email"
|
|
|
|
andAttribute: @"type"
|
|
|
|
havingValue: @"pref"]];
|
|
|
|
|
|
|
|
max = [emails count];
|
|
|
|
for (count = 0; !stringValue && count < max; count++)
|
|
|
|
{
|
2011-11-14 04:26:50 +01:00
|
|
|
email = [[emails objectAtIndex: count] flattenedValuesForKey: @""];
|
2011-04-13 21:59:04 +02:00
|
|
|
|
|
|
|
if ([email caseInsensitiveCompare: [card preferredEMail]] != NSOrderedSame)
|
|
|
|
stringValue = email;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!stringValue)
|
|
|
|
stringValue = @"";
|
|
|
|
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidEmail2OriginalDisplayName: (void **) data // Other email
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
return [self getPidLidEmail2EmailAddress: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagBody: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-10-24 22:47:55 +02:00
|
|
|
int rc = MAPISTORE_SUCCESS;
|
2011-04-13 21:59:04 +02:00
|
|
|
NSString *stringValue;
|
|
|
|
|
|
|
|
stringValue = [[sogoObject vCard] note];
|
2011-10-24 22:47:55 +02:00
|
|
|
if ([stringValue length] > 0)
|
2011-11-14 04:26:50 +01:00
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
2011-10-24 22:47:55 +02:00
|
|
|
else
|
|
|
|
rc = MAPISTORE_ERR_NOT_FOUND;
|
2011-04-13 21:59:04 +02:00
|
|
|
|
2011-10-24 22:47:55 +02:00
|
|
|
return rc;
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) _getElement: (NSString *) elementTag
|
|
|
|
ofType: (NSString *) aType
|
|
|
|
excluding: (NSString *) aTypeToExclude
|
|
|
|
atPos: (NSUInteger) pos
|
|
|
|
inData: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-02-24 21:30:01 +01:00
|
|
|
{
|
|
|
|
NSArray *elements;
|
2011-04-13 21:59:04 +02:00
|
|
|
CardElement *ce;
|
2011-02-24 21:30:01 +01:00
|
|
|
NSUInteger count, max;
|
2011-04-13 21:59:04 +02:00
|
|
|
NGVCard *vCard;
|
|
|
|
NSString *stringValue;
|
2011-02-24 21:30:01 +01:00
|
|
|
|
2011-04-13 21:59:04 +02:00
|
|
|
stringValue = nil;
|
2011-02-24 21:30:01 +01:00
|
|
|
|
2011-04-13 21:59:04 +02:00
|
|
|
vCard = [sogoObject vCard];
|
|
|
|
elements = [[vCard childrenWithTag: elementTag]
|
2011-02-24 21:30:01 +01:00
|
|
|
cardElementsWithAttribute: @"type"
|
|
|
|
havingValue: aType];
|
|
|
|
max = [elements count];
|
2011-04-13 21:59:04 +02:00
|
|
|
for (count = 0; !stringValue && count < max; count++)
|
2011-02-24 21:30:01 +01:00
|
|
|
{
|
|
|
|
ce = [elements objectAtIndex: count];
|
|
|
|
if (!aTypeToExclude
|
|
|
|
|| ![ce hasAttribute: @"type" havingValue: aTypeToExclude])
|
2011-11-14 04:26:50 +01:00
|
|
|
stringValue = [ce flattenedValueAtIndex: pos forKey: @""];
|
2011-02-24 21:30:01 +01:00
|
|
|
}
|
|
|
|
|
2011-04-13 21:59:04 +02:00
|
|
|
if (!stringValue)
|
|
|
|
stringValue = @"";
|
|
|
|
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagBusinessTelephoneNumber: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
return [self _getElement: @"tel" ofType: @"work" excluding: @"fax"
|
2011-07-11 23:40:47 +02:00
|
|
|
atPos: 0 inData: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagHomeTelephoneNumber: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
return [self _getElement: @"tel" ofType: @"home" excluding: @"fax"
|
2011-07-11 23:40:47 +02:00
|
|
|
atPos: 0 inData: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagMobileTelephoneNumber: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
return [self _getElement: @"tel" ofType: @"cell" excluding: nil
|
2011-07-11 23:40:47 +02:00
|
|
|
atPos: 0 inData: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagPagerTelephoneNumber: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-09-14 20:33:44 +02:00
|
|
|
{
|
|
|
|
return [self _getElement: @"tel" ofType: @"pager" excluding: nil
|
|
|
|
atPos: 0 inData: data inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagPrimaryTelephoneNumber: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
return [self _getElement: @"tel" ofType: @"pref" excluding: nil
|
2011-07-11 23:40:47 +02:00
|
|
|
atPos: 0 inData: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagBusinessFaxNumber: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-09-14 20:33:44 +02:00
|
|
|
{
|
|
|
|
return [self _getElement: @"tel" ofType: @"fax" excluding: nil
|
|
|
|
atPos: 0 inData: data inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagBusinessHomePage: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
return [self _getElement: @"url" ofType: @"work" excluding: nil
|
2011-07-11 23:40:47 +02:00
|
|
|
atPos: 0 inData: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagPersonalHomePage: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
return [self _getElement: @"url" ofType: @"home" excluding: nil
|
2011-07-11 23:40:47 +02:00
|
|
|
atPos: 0 inData: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidEmail1AddressType: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
return [self getSMTPAddrType: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidEmail2AddressType: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
return [self getSMTPAddrType: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidEmail3AddressType: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
return [self getSMTPAddrType: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidInstantMessagingAddress: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
NSString *stringValue;
|
|
|
|
|
|
|
|
stringValue = [[[sogoObject vCard] uniqueChildWithTag: @"x-aim"]
|
2011-11-14 04:26:50 +01:00
|
|
|
flattenedValuesForKey: @""];
|
2011-04-13 21:59:04 +02:00
|
|
|
if (!stringValue)
|
|
|
|
stringValue = @"";
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
2011-02-24 21:30:01 +01:00
|
|
|
}
|
|
|
|
|
2011-04-13 21:59:04 +02:00
|
|
|
- (int) getPidLidPostalAddressId: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-02-24 21:30:01 +01:00
|
|
|
{
|
2011-04-13 21:59:04 +02:00
|
|
|
NSArray *elements;
|
2011-02-24 21:30:01 +01:00
|
|
|
CardElement *element;
|
2011-04-13 21:59:04 +02:00
|
|
|
uint32_t longValue = 0;
|
2011-02-24 21:30:01 +01:00
|
|
|
NGVCard *vCard;
|
|
|
|
|
2011-04-13 21:59:04 +02:00
|
|
|
vCard = [sogoObject vCard];
|
|
|
|
elements = [[vCard childrenWithTag: @"adr"]
|
|
|
|
cardElementsWithAttribute: @"type"
|
|
|
|
havingValue: @"pref"];
|
|
|
|
if ([elements count] > 0)
|
2011-02-24 21:30:01 +01:00
|
|
|
{
|
2011-04-13 21:59:04 +02:00
|
|
|
element = [elements objectAtIndex: 0];
|
2011-02-24 21:30:01 +01:00
|
|
|
if ([element hasAttribute: @"type"
|
2011-04-13 21:59:04 +02:00
|
|
|
havingValue: @"home"])
|
|
|
|
longValue = 1; // The Home Address is the mailing address.
|
2011-02-24 21:30:01 +01:00
|
|
|
else if ([element hasAttribute: @"type"
|
2011-04-13 21:59:04 +02:00
|
|
|
havingValue: @"work"])
|
|
|
|
longValue = 2; // The Work Address is the mailing address.
|
|
|
|
}
|
|
|
|
*data = MAPILongValue (memCtx, longValue);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-09-14 20:33:44 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// getters when no address is selected as the Mailing Address
|
|
|
|
//
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagPostalAddress: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
return [self _getElement: @"label" ofType: @"pref" excluding: nil
|
2011-07-11 23:40:47 +02:00
|
|
|
atPos: 0 inData: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagPostOfficeBox: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
return [self _getElement: @"adr" ofType: @"pref" excluding: nil
|
2011-07-11 23:40:47 +02:00
|
|
|
atPos: 0 inData: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagStreetAddress: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
return [self _getElement: @"adr" ofType: @"pref" excluding: nil
|
2011-07-11 23:40:47 +02:00
|
|
|
atPos: 2 inData: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagLocality: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
return [self _getElement: @"adr" ofType: @"pref" excluding: nil
|
2011-07-11 23:40:47 +02:00
|
|
|
atPos: 3 inData: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagStateOrProvince: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
return [self _getElement: @"adr" ofType: @"pref" excluding: nil
|
2011-07-11 23:40:47 +02:00
|
|
|
atPos: 4 inData: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagPostalCode: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
return [self _getElement: @"adr" ofType: @"pref" excluding: nil
|
2011-07-11 23:40:47 +02:00
|
|
|
atPos: 5 inData: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagCountry: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
return [self _getElement: @"adr" ofType: @"pref" excluding: nil
|
2011-07-11 23:40:47 +02:00
|
|
|
atPos: 6 inData: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2011-09-14 20:33:44 +02:00
|
|
|
//
|
|
|
|
// home address getters
|
|
|
|
//
|
|
|
|
- (int) getPidLidHomeAddress: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [self _getElement: @"label" ofType: @"home" excluding: nil
|
|
|
|
atPos: 0 inData: data inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagHomeAddressPostOfficeBox: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-09-14 20:33:44 +02:00
|
|
|
{
|
|
|
|
return [self _getElement: @"adr" ofType: @"home" excluding: nil
|
|
|
|
atPos: 0 inData: data inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagHomeAddressStreet: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-09-14 20:33:44 +02:00
|
|
|
{
|
|
|
|
return [self _getElement: @"adr" ofType: @"home" excluding: nil
|
|
|
|
atPos: 2 inData: data inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagHomeAddressCity: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-09-14 20:33:44 +02:00
|
|
|
{
|
|
|
|
return [self _getElement: @"adr" ofType: @"home" excluding: nil
|
|
|
|
atPos: 3 inData: data inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagHomeAddressStateOrProvince: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-09-14 20:33:44 +02:00
|
|
|
{
|
|
|
|
return [self _getElement: @"adr" ofType: @"home" excluding: nil
|
|
|
|
atPos: 4 inData: data inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagHomeAddressPostalCode: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-09-14 20:33:44 +02:00
|
|
|
{
|
|
|
|
return [self _getElement: @"adr" ofType: @"home" excluding: nil
|
|
|
|
atPos: 5 inData: data inMemCtx: memCtx];
|
|
|
|
}
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagHomeAddressCountry: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-09-14 20:33:44 +02:00
|
|
|
{
|
|
|
|
return [self _getElement: @"adr" ofType: @"home" excluding: nil
|
|
|
|
atPos: 6 inData: data inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Work addresss
|
|
|
|
//
|
2011-04-13 21:59:04 +02:00
|
|
|
- (int) getPidLidWorkAddress: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
return [self _getElement: @"label" ofType: @"work" excluding: nil
|
2011-07-11 23:40:47 +02:00
|
|
|
atPos: 0 inData: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidWorkAddressPostOfficeBox: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
return [self _getElement: @"adr" ofType: @"work" excluding: nil
|
2011-07-11 23:40:47 +02:00
|
|
|
atPos: 0 inData: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidWorkAddressStreet: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
return [self _getElement: @"adr" ofType: @"work" excluding: nil
|
2011-07-11 23:40:47 +02:00
|
|
|
atPos: 2 inData: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidWorkAddressCity: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
return [self _getElement: @"adr" ofType: @"work" excluding: nil
|
2011-07-11 23:40:47 +02:00
|
|
|
atPos: 3 inData: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidWorkAddressState: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
return [self _getElement: @"adr" ofType: @"work" excluding: nil
|
2011-07-11 23:40:47 +02:00
|
|
|
atPos: 4 inData: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidWorkAddressPostalCode: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
return [self _getElement: @"adr" ofType: @"work" excluding: nil
|
2011-07-11 23:40:47 +02:00
|
|
|
atPos: 5 inData: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidWorkAddressCountry: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
return [self _getElement: @"adr" ofType: @"work" excluding: nil
|
2011-07-11 23:40:47 +02:00
|
|
|
atPos: 6 inData: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2011-09-14 20:33:44 +02:00
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagNickname: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
NSString *stringValue;
|
|
|
|
|
|
|
|
stringValue = [[sogoObject vCard] nickname];
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagBirthday: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
NSCalendarDate *dateValue;
|
|
|
|
NSString *stringValue;
|
|
|
|
int rc = MAPISTORE_SUCCESS;
|
|
|
|
|
|
|
|
stringValue = [[sogoObject vCard] bday];
|
|
|
|
if (stringValue)
|
|
|
|
{
|
|
|
|
dateValue = [NSCalendarDate dateWithString: stringValue
|
|
|
|
calendarFormat: @"%Y-%m-%d"];
|
2011-09-23 20:16:46 +02:00
|
|
|
//dateValue = [dateValue addYear: 0 month: 0 day: 1 hour: 0 minute: 0 second: 0];
|
2011-04-13 21:59:04 +02:00
|
|
|
*data = [dateValue asFileTimeInMemCtx: memCtx];
|
2011-02-24 21:30:01 +01:00
|
|
|
}
|
2011-04-13 21:59:04 +02:00
|
|
|
else
|
|
|
|
rc = MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
|
2011-02-24 21:30:01 +01:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-09-23 03:00:28 +02:00
|
|
|
//
|
|
|
|
// Decomposed fullname getters
|
|
|
|
//
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSurname: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-09-23 03:00:28 +02:00
|
|
|
{
|
|
|
|
NSString *stringValue;
|
|
|
|
|
2011-11-14 04:26:50 +01:00
|
|
|
stringValue = [[[sogoObject vCard] firstChildWithTag: @"n"]
|
|
|
|
flattenedValueAtIndex: 0
|
|
|
|
forKey: @""];
|
2011-09-23 03:00:28 +02:00
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagGivenName: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-09-23 03:00:28 +02:00
|
|
|
{
|
|
|
|
NSString *stringValue;
|
|
|
|
|
2011-11-14 04:26:50 +01:00
|
|
|
stringValue = [[[sogoObject vCard] firstChildWithTag: @"n"]
|
|
|
|
flattenedValueAtIndex: 1
|
|
|
|
forKey: @""];
|
2011-09-23 03:00:28 +02:00
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagMiddleName: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-09-23 03:00:28 +02:00
|
|
|
{
|
|
|
|
NSString *stringValue;
|
|
|
|
|
2011-11-14 04:26:50 +01:00
|
|
|
stringValue = [[[sogoObject vCard] firstChildWithTag: @"n"]
|
|
|
|
flattenedValueAtIndex: 2
|
|
|
|
forKey: @""];
|
2011-09-23 03:00:28 +02:00
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagDisplayNamePrefix: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-09-23 03:00:28 +02:00
|
|
|
{
|
|
|
|
NSString *stringValue;
|
|
|
|
|
2011-11-14 04:26:50 +01:00
|
|
|
stringValue = [[[sogoObject vCard] firstChildWithTag: @"n"]
|
|
|
|
flattenedValueAtIndex: 3
|
|
|
|
forKey: @""];
|
2011-09-23 03:00:28 +02:00
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagGeneration: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-09-23 03:00:28 +02:00
|
|
|
{
|
|
|
|
NSString *stringValue;
|
|
|
|
|
2011-11-14 04:26:50 +01:00
|
|
|
stringValue = [[[sogoObject vCard] firstChildWithTag: @"n"]
|
|
|
|
flattenedValueAtIndex: 4
|
|
|
|
forKey: @""];
|
2011-09-23 03:00:28 +02:00
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSensitivity: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-11-23 15:40:41 +01:00
|
|
|
{
|
|
|
|
return [self getLongZero: data inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2011-10-24 22:47:55 +02:00
|
|
|
/* attachments (photos) */
|
|
|
|
- (void) _fetchAttachmentParts
|
|
|
|
{
|
|
|
|
NGVCardPhoto *photo;
|
|
|
|
MAPIStoreContactsAttachment *attachment;
|
|
|
|
NSString *encoding;
|
|
|
|
|
|
|
|
photo = (NGVCardPhoto *) [[sogoObject vCard] firstChildWithTag: @"photo"];
|
|
|
|
if (photo)
|
|
|
|
{
|
|
|
|
encoding = [[photo value: 0 ofAttribute: @"encoding"] uppercaseString];
|
|
|
|
if ([encoding isEqualToString: @"B"]
|
|
|
|
|| [encoding isEqualToString: @"BASE64"])
|
|
|
|
{
|
|
|
|
attachment = [MAPIStoreContactsAttachment
|
|
|
|
mapiStoreObjectWithSOGoObject: nil
|
|
|
|
inContainer: self];
|
|
|
|
[attachment setAID: 0];
|
|
|
|
[attachment setPhoto: photo];
|
|
|
|
[attachmentParts setObject: attachment forKey: @"photo"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fetchedAttachments = YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidHasPicture: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
if (!fetchedAttachments)
|
|
|
|
[self _fetchAttachmentParts];
|
|
|
|
|
|
|
|
*data = MAPIBoolValue (memCtx, ([attachmentParts count] > 0));
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) attachmentKeysMatchingQualifier: (EOQualifier *) qualifier
|
|
|
|
andSortOrderings: (NSArray *) sortOrderings
|
|
|
|
{
|
|
|
|
if (!fetchedAttachments)
|
|
|
|
[self _fetchAttachmentParts];
|
|
|
|
|
|
|
|
return [super attachmentKeysMatchingQualifier: qualifier
|
|
|
|
andSortOrderings: sortOrderings];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) lookupAttachment: (NSString *) childKey
|
|
|
|
{
|
|
|
|
if (!fetchedAttachments)
|
|
|
|
[self _fetchAttachmentParts];
|
|
|
|
|
|
|
|
return [attachmentParts objectForKey: childKey];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) _updatePhotoInVCard: (NGVCard *) card
|
2012-03-02 21:44:24 +01:00
|
|
|
fromProperties: (NSDictionary *) attachmentProps
|
2011-10-24 22:47:55 +02:00
|
|
|
{
|
|
|
|
NSString *photoExt, *photoType, *content;
|
|
|
|
CardElement *photo;
|
|
|
|
|
|
|
|
if ([[attachmentProps
|
|
|
|
objectForKey: MAPIPropertyKey (PR_ATTACHMENT_CONTACTPHOTO)]
|
|
|
|
boolValue])
|
|
|
|
{
|
|
|
|
photoExt = [[attachmentProps
|
|
|
|
objectForKey: MAPIPropertyKey (PR_ATTACH_EXTENSION_UNICODE)]
|
|
|
|
uppercaseString];
|
|
|
|
if ([photoExt isEqualToString: @".JPG"])
|
|
|
|
photoType = @"JPEG";
|
|
|
|
else if ([photoExt isEqualToString: @".PNG"])
|
|
|
|
photoType = @"PNG";
|
|
|
|
else if ([photoExt isEqualToString: @".BMP"])
|
|
|
|
photoType = @"BMP";
|
|
|
|
else if ([photoExt isEqualToString: @".GIF"])
|
|
|
|
photoType = @"GIF";
|
|
|
|
else
|
|
|
|
photoType = nil;
|
|
|
|
|
|
|
|
content = [[attachmentProps
|
|
|
|
objectForKey: MAPIPropertyKey (PR_ATTACH_DATA_BIN)]
|
|
|
|
stringByEncodingBase64];
|
|
|
|
if (photoType && content)
|
|
|
|
{
|
|
|
|
photo = [card uniqueChildWithTag: @"photo"];
|
|
|
|
[photo setValue: 0 ofAttribute: @"type"
|
|
|
|
to: photoType];
|
|
|
|
[photo setValue: 0 ofAttribute: @"encoding"
|
|
|
|
to: @"b"];
|
2011-11-14 04:26:50 +01:00
|
|
|
[photo setSingleValue: [content stringByReplacingString: @"\n"
|
|
|
|
withString: @""]
|
|
|
|
atIndex: 0 forKey: @""];
|
2011-10-24 22:47:55 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-01 22:13:09 +01:00
|
|
|
- (BOOL) subscriberCanReadMessage
|
|
|
|
{
|
|
|
|
return [[self activeUserRoles] containsObject: SOGoRole_ObjectViewer];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) subscriberCanModifyMessage
|
|
|
|
{
|
|
|
|
NSArray *roles;
|
|
|
|
|
|
|
|
roles = [self activeUserRoles];
|
|
|
|
|
|
|
|
return ((isNew
|
|
|
|
&& [roles containsObject: SOGoRole_ObjectCreator])
|
|
|
|
|| (!isNew && [roles containsObject: SOGoRole_ObjectEditor]));
|
|
|
|
}
|
|
|
|
|
2011-09-23 03:00:28 +02:00
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
2011-02-24 21:30:01 +01:00
|
|
|
- (void) save
|
|
|
|
{
|
2011-09-14 20:33:44 +02:00
|
|
|
NSArray *elements, *units;
|
2011-02-24 21:30:01 +01:00
|
|
|
CardElement *element;
|
2011-09-14 20:33:44 +02:00
|
|
|
NGVCard *newCard;
|
2011-10-24 22:47:55 +02:00
|
|
|
MAPIStoreAttachment *attachment;
|
2011-02-24 21:30:01 +01:00
|
|
|
int postalAddressId;
|
|
|
|
id value;
|
|
|
|
|
2011-10-26 17:15:17 +02:00
|
|
|
[self logWithFormat: @"setMAPIProperties: %@", properties];
|
2011-02-24 21:30:01 +01:00
|
|
|
|
|
|
|
newCard = [sogoObject vCard];
|
|
|
|
[newCard setTag: @"vcard"];
|
|
|
|
[newCard setVersion: @"3.0"];
|
|
|
|
[newCard setProdID: @"-//Inverse inc.//OpenChange+SOGo//EN"];
|
|
|
|
[newCard setProfile: @"vCard"];
|
2011-09-14 20:33:44 +02:00
|
|
|
|
|
|
|
// Decomposed fullname
|
2011-10-26 17:15:17 +02:00
|
|
|
[newCard setNWithFamily: [properties objectForKey: MAPIPropertyKey(PR_SURNAME_UNICODE)]
|
2012-03-02 21:44:24 +01:00
|
|
|
given: [properties objectForKey: MAPIPropertyKey(PR_GIVEN_NAME_UNICODE)]
|
|
|
|
additional: [properties objectForKey: MAPIPropertyKey(PR_MIDDLE_NAME_UNICODE)]
|
|
|
|
prefixes: [properties objectForKey: MAPIPropertyKey(PR_DISPLAY_NAME_PREFIX_UNICODE)]
|
|
|
|
suffixes: [properties objectForKey: MAPIPropertyKey(PR_GENERATION_UNICODE)]];
|
2011-09-14 20:33:44 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// display name
|
|
|
|
//
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PR_DISPLAY_NAME_UNICODE)];
|
2011-02-24 21:30:01 +01:00
|
|
|
if (value)
|
|
|
|
[newCard setFn: value];
|
|
|
|
|
2011-09-14 20:33:44 +02:00
|
|
|
//
|
|
|
|
// email addresses handling
|
|
|
|
//
|
2011-02-24 21:30:01 +01:00
|
|
|
elements = [newCard childrenWithTag: @"email"];
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PidLidEmail1EmailAddress)];
|
2011-02-24 21:30:01 +01:00
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
if ([elements count] > 0)
|
2011-11-14 04:26:50 +01:00
|
|
|
[[elements objectAtIndex: 0] setSingleValue: value forKey: @""];
|
2011-02-24 21:30:01 +01:00
|
|
|
else
|
|
|
|
[newCard addEmail: value
|
|
|
|
types: [NSArray arrayWithObject: @"pref"]];
|
|
|
|
}
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PidLidEmail2EmailAddress)];
|
2011-02-24 21:30:01 +01:00
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
if ([elements count] > 1)
|
2011-11-14 04:26:50 +01:00
|
|
|
[[elements objectAtIndex: 1] setSingleValue: value forKey: @""];
|
2011-02-24 21:30:01 +01:00
|
|
|
else
|
|
|
|
[newCard addEmail: value types: nil];
|
|
|
|
}
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PidLidEmail3EmailAddress)];
|
2011-02-24 21:30:01 +01:00
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
if ([elements count] > 2)
|
2011-11-14 04:26:50 +01:00
|
|
|
[[elements objectAtIndex: 2] setSingleValue: value forKey: @""];
|
2011-02-24 21:30:01 +01:00
|
|
|
else
|
|
|
|
[newCard addEmail: value types: nil];
|
|
|
|
}
|
|
|
|
|
2011-09-14 20:33:44 +02:00
|
|
|
//
|
|
|
|
// work postal addresses handling
|
|
|
|
//
|
|
|
|
// Possible values for PidLidPostalAddressId are:
|
|
|
|
//
|
|
|
|
// 0x00000000 - No address is selected as the Mailing Address.
|
|
|
|
// 0x00000001 - The Home Address is the Mailing Address.
|
|
|
|
// 0x00000002 - The Work Address is the Mailing Address
|
|
|
|
// 0x00000003 - The Other Address is the Mailing Address.
|
|
|
|
//
|
|
|
|
//
|
2011-10-26 17:15:17 +02:00
|
|
|
postalAddressId = [[properties objectForKey: MAPIPropertyKey (PidLidPostalAddressId)]
|
2011-02-24 21:30:01 +01:00
|
|
|
intValue];
|
2011-09-14 20:33:44 +02:00
|
|
|
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PidLidWorkAddress)];
|
2011-02-24 21:30:01 +01:00
|
|
|
if ([value length])
|
|
|
|
{
|
|
|
|
elements = [newCard childrenWithTag: @"label"
|
|
|
|
andAttribute: @"type"
|
|
|
|
havingValue: @"work"];
|
|
|
|
if ([elements count] > 0)
|
|
|
|
element = [elements objectAtIndex: 0];
|
|
|
|
else
|
|
|
|
{
|
|
|
|
element = [CardElement elementWithTag: @"label"];
|
|
|
|
[element addAttribute: @"type" value: @"work"];
|
|
|
|
[newCard addChild: element];
|
|
|
|
}
|
|
|
|
if (postalAddressId == 2)
|
|
|
|
{
|
|
|
|
[element removeValue: @"pref"
|
|
|
|
fromAttribute: @"type"];
|
|
|
|
[element addAttribute: @"type"
|
|
|
|
value: @"pref"];
|
|
|
|
}
|
2011-11-14 04:26:50 +01:00
|
|
|
[element setSingleValue: value forKey: @""];
|
2011-02-24 21:30:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
elements = [newCard childrenWithTag: @"adr"
|
|
|
|
andAttribute: @"type"
|
|
|
|
havingValue: @"work"];
|
|
|
|
if ([elements count] > 0)
|
|
|
|
element = [elements objectAtIndex: 0];
|
|
|
|
else
|
|
|
|
{
|
|
|
|
element = [CardElement elementWithTag: @"adr"];
|
|
|
|
[element addAttribute: @"type" value: @"work"];
|
|
|
|
[newCard addChild: element];
|
|
|
|
}
|
|
|
|
if (postalAddressId == 2)
|
2011-07-11 23:40:47 +02:00
|
|
|
[element addAttribute: @"type" value: @"pref"];
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PidLidWorkAddressPostOfficeBox)];
|
2011-09-14 20:33:44 +02:00
|
|
|
if (value)
|
2011-11-14 04:26:50 +01:00
|
|
|
[element setSingleValue: value atIndex: 0 forKey: @""];
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PidLidWorkAddressStreet)];
|
2011-09-14 20:33:44 +02:00
|
|
|
if (value)
|
2011-11-14 04:26:50 +01:00
|
|
|
[element setSingleValue: value atIndex: 2 forKey: @""];
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PidLidWorkAddressCity)];
|
2011-09-14 20:33:44 +02:00
|
|
|
if (value)
|
2011-11-14 04:26:50 +01:00
|
|
|
[element setSingleValue: value atIndex: 3 forKey: @""];
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PidLidWorkAddressState)];
|
2011-09-14 20:33:44 +02:00
|
|
|
if (value)
|
2011-11-14 04:26:50 +01:00
|
|
|
[element setSingleValue: value atIndex: 4 forKey: @""];
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PidLidWorkAddressPostalCode)];
|
2011-09-14 20:33:44 +02:00
|
|
|
if (value)
|
2011-11-14 04:26:50 +01:00
|
|
|
[element setSingleValue: value atIndex: 5 forKey: @""];
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PidLidWorkAddressCountry)];
|
2011-09-14 20:33:44 +02:00
|
|
|
if (value)
|
2011-11-14 04:26:50 +01:00
|
|
|
[element setSingleValue: value atIndex: 6 forKey: @""];
|
2011-09-14 20:33:44 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// home postal addresses handling
|
|
|
|
//
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PidLidHomeAddress)];
|
2011-09-14 20:33:44 +02:00
|
|
|
if ([value length])
|
|
|
|
{
|
|
|
|
elements = [newCard childrenWithTag: @"label"
|
|
|
|
andAttribute: @"type"
|
|
|
|
havingValue: @"home"];
|
|
|
|
if ([elements count] > 0)
|
|
|
|
element = [elements objectAtIndex: 0];
|
|
|
|
else
|
|
|
|
{
|
|
|
|
element = [CardElement elementWithTag: @"label"];
|
|
|
|
[element addAttribute: @"type" value: @"home"];
|
|
|
|
[newCard addChild: element];
|
|
|
|
}
|
|
|
|
if (postalAddressId == 1)
|
|
|
|
{
|
|
|
|
[element removeValue: @"pref"
|
|
|
|
fromAttribute: @"type"];
|
|
|
|
[element addAttribute: @"type"
|
|
|
|
value: @"pref"];
|
|
|
|
}
|
2011-11-14 04:26:50 +01:00
|
|
|
[element setSingleValue: value forKey: @""];
|
2011-09-14 20:33:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
elements = [newCard childrenWithTag: @"adr"
|
|
|
|
andAttribute: @"type"
|
|
|
|
havingValue: @"home"];
|
|
|
|
if ([elements count] > 0)
|
|
|
|
element = [elements objectAtIndex: 0];
|
|
|
|
else
|
|
|
|
{
|
|
|
|
element = [CardElement elementWithTag: @"adr"];
|
|
|
|
[element addAttribute: @"type" value: @"home"];
|
|
|
|
[newCard addChild: element];
|
|
|
|
}
|
|
|
|
if (postalAddressId == 1)
|
|
|
|
[element addAttribute: @"type" value: @"pref"];
|
|
|
|
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PR_HOME_ADDRESS_POST_OFFICE_BOX_UNICODE)];
|
2011-02-24 21:30:01 +01:00
|
|
|
if (value)
|
2011-11-14 04:26:50 +01:00
|
|
|
[element setSingleValue: value atIndex: 0 forKey: @""];
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey( PR_HOME_ADDRESS_STREET_UNICODE)];
|
2011-02-24 21:30:01 +01:00
|
|
|
if (value)
|
2011-11-14 04:26:50 +01:00
|
|
|
[element setSingleValue: value atIndex: 2 forKey: @""];
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PR_HOME_ADDRESS_CITY_UNICODE)];
|
2011-02-24 21:30:01 +01:00
|
|
|
if (value)
|
2011-11-14 04:26:50 +01:00
|
|
|
[element setSingleValue: value atIndex: 3 forKey: @""];
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PR_HOME_ADDRESS_STATE_OR_PROVINCE_UNICODE)];
|
2011-02-24 21:30:01 +01:00
|
|
|
if (value)
|
2011-11-14 04:26:50 +01:00
|
|
|
[element setSingleValue: value atIndex: 4 forKey: @""];
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PR_HOME_ADDRESS_POSTAL_CODE_UNICODE)];
|
2011-02-24 21:30:01 +01:00
|
|
|
if (value)
|
2011-11-14 04:26:50 +01:00
|
|
|
[element setSingleValue: value atIndex: 5 forKey: @""];
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PR_HOME_ADDRESS_COUNTRY_UNICODE)];
|
2011-02-24 21:30:01 +01:00
|
|
|
if (value)
|
2011-11-14 04:26:50 +01:00
|
|
|
[element setSingleValue: value atIndex: 6 forKey: @""];
|
2011-02-24 21:30:01 +01:00
|
|
|
|
2011-09-14 20:33:44 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// telephone numbers: work, home, fax, pager and mobile
|
|
|
|
//
|
|
|
|
element = [self _elementWithTag: @"tel" ofType: @"work" forCard: newCard];
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PR_OFFICE_TELEPHONE_NUMBER_UNICODE)];
|
2011-09-14 20:33:44 +02:00
|
|
|
if (value)
|
2011-11-14 04:26:50 +01:00
|
|
|
[element setSingleValue: value forKey: @""];
|
2011-09-14 20:33:44 +02:00
|
|
|
|
|
|
|
element = [self _elementWithTag: @"tel" ofType: @"home" forCard: newCard];
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PR_HOME_TELEPHONE_NUMBER_UNICODE)];
|
2011-09-14 20:33:44 +02:00
|
|
|
if (value)
|
2011-11-14 04:26:50 +01:00
|
|
|
[element setSingleValue: value forKey: @""];
|
2011-09-14 20:33:44 +02:00
|
|
|
|
|
|
|
element = [self _elementWithTag: @"tel" ofType: @"fax" forCard: newCard];
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PR_BUSINESS_FAX_NUMBER_UNICODE)];
|
2011-09-14 20:33:44 +02:00
|
|
|
if (value)
|
2011-11-14 04:26:50 +01:00
|
|
|
[element setSingleValue: value forKey: @""];
|
2011-09-14 20:33:44 +02:00
|
|
|
|
|
|
|
element = [self _elementWithTag: @"tel" ofType: @"pager" forCard: newCard];
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PR_PAGER_TELEPHONE_NUMBER_UNICODE)];
|
2011-09-14 20:33:44 +02:00
|
|
|
if (value)
|
2011-11-14 04:26:50 +01:00
|
|
|
[element setSingleValue: value forKey: @""];
|
2011-09-14 20:33:44 +02:00
|
|
|
|
|
|
|
element = [self _elementWithTag: @"tel" ofType: @"cell" forCard: newCard];
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PR_MOBILE_TELEPHONE_NUMBER_UNICODE)];
|
2011-09-14 20:33:44 +02:00
|
|
|
if (value)
|
2011-11-14 04:26:50 +01:00
|
|
|
[element setSingleValue: value forKey: @""];
|
2011-09-14 20:33:44 +02:00
|
|
|
|
|
|
|
|
|
|
|
//
|
2011-09-23 20:16:46 +02:00
|
|
|
// job title, nickname, company name, deparment, work url, im address/screen name and birthday
|
2011-09-14 20:33:44 +02:00
|
|
|
//
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PR_TITLE_UNICODE)];
|
2011-09-14 20:33:44 +02:00
|
|
|
if (value)
|
|
|
|
[newCard setTitle: value];
|
|
|
|
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PR_NICKNAME_UNICODE)];
|
2011-09-14 20:33:44 +02:00
|
|
|
if (value)
|
|
|
|
[newCard setNickname: value];
|
|
|
|
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PR_DEPARTMENT_NAME_UNICODE)];
|
2011-09-14 20:33:44 +02:00
|
|
|
if (value)
|
|
|
|
units = [NSArray arrayWithObject: value];
|
|
|
|
else
|
|
|
|
units = nil;
|
|
|
|
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PR_COMPANY_NAME_UNICODE)];
|
2011-09-14 20:33:44 +02:00
|
|
|
if (value)
|
|
|
|
[newCard setOrg: value units: units];
|
|
|
|
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PR_BUSINESS_HOME_PAGE_UNICODE)];
|
2011-09-14 20:33:44 +02:00
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
[[self _elementWithTag: @"url" ofType: @"work" forCard: newCard]
|
2011-11-14 04:26:50 +01:00
|
|
|
setSingleValue: value forKey: @""];
|
2011-09-14 20:33:44 +02:00
|
|
|
}
|
|
|
|
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PidLidInstantMessagingAddress)];
|
2011-09-14 20:33:44 +02:00
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
[[newCard uniqueChildWithTag: @"x-aim"]
|
2011-11-14 04:26:50 +01:00
|
|
|
setSingleValue: value forKey: @""];
|
2011-09-20 21:37:03 +02:00
|
|
|
}
|
2011-09-14 20:33:44 +02:00
|
|
|
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PR_BIRTHDAY)];
|
2011-09-23 20:16:46 +02:00
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
[newCard setBday: [value descriptionWithCalendarFormat: @"%Y-%m-%d"]];
|
|
|
|
}
|
|
|
|
|
2011-10-24 22:47:55 +02:00
|
|
|
/* photo */
|
|
|
|
if ([attachmentParts count] > 0)
|
|
|
|
{
|
|
|
|
attachment = [[attachmentParts allValues] objectAtIndex: 0];
|
|
|
|
[self _updatePhotoInVCard: newCard
|
2011-10-26 17:15:17 +02:00
|
|
|
fromProperties: [attachment properties]];
|
2011-10-24 22:47:55 +02:00
|
|
|
}
|
2011-09-23 20:16:46 +02:00
|
|
|
|
2011-11-09 21:10:31 +01:00
|
|
|
/* Note */
|
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PR_BODY_UNICODE)];
|
|
|
|
if (!value)
|
|
|
|
{
|
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PR_HTML)];
|
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
value = [[NSString alloc] initWithData: value
|
|
|
|
encoding: NSUTF8StringEncoding];
|
|
|
|
[value autorelease];
|
|
|
|
value = [value htmlToText];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (value)
|
|
|
|
[newCard setNote: value];
|
|
|
|
|
2011-09-14 20:33:44 +02:00
|
|
|
//
|
|
|
|
// we save the new/modified card
|
|
|
|
//
|
2011-02-24 21:30:01 +01:00
|
|
|
[sogoObject saveContentString: [newCard versitString]];
|
2012-03-16 22:05:41 +01:00
|
|
|
|
|
|
|
[self updateVersions];
|
2011-02-24 21:30:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|