2010-12-30 15:34:44 +01:00
|
|
|
/* MAPIStoreContactsMessageTable.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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#import <Foundation/NSDictionary.h>
|
|
|
|
#import <Foundation/NSString.h>
|
|
|
|
|
|
|
|
#import <EOControl/EOQualifier.h>
|
|
|
|
|
|
|
|
#import <NGCards/NSArray+NGCards.h>
|
|
|
|
#import <NGCards/NGVCard.h>
|
|
|
|
|
|
|
|
#import <Contacts/SOGoContactGCSEntry.h>
|
|
|
|
|
|
|
|
#import "MAPIStoreTypes.h"
|
2011-01-14 14:13:32 +01:00
|
|
|
#import "NSCalendarDate+MAPIStore.h"
|
2011-02-10 18:54:35 +01:00
|
|
|
#import "NSArray+MAPIStore.h"
|
|
|
|
#import "NSData+MAPIStore.h"
|
2010-12-30 15:34:44 +01:00
|
|
|
#import "NSString+MAPIStore.h"
|
|
|
|
|
|
|
|
#import "MAPIStoreContactsMessageTable.h"
|
|
|
|
|
|
|
|
#include <mapistore/mapistore_nameid.h>
|
|
|
|
|
|
|
|
@implementation MAPIStoreContactsMessageTable
|
|
|
|
|
|
|
|
- (EOQualifier *) componentQualifier
|
|
|
|
{
|
|
|
|
static EOQualifier *componentQualifier = nil;
|
|
|
|
|
|
|
|
/* TODO: we need to support vlist as well */
|
|
|
|
if (!componentQualifier)
|
|
|
|
componentQualifier
|
|
|
|
= [[EOKeyValueQualifier alloc] initWithKey: @"c_component"
|
|
|
|
operatorSelector: EOQualifierOperatorEqual
|
|
|
|
value: @"vcard"];
|
|
|
|
|
|
|
|
return componentQualifier;
|
|
|
|
}
|
|
|
|
|
2011-01-11 22:21:42 +01:00
|
|
|
- (CardElement *) _element: (NSString *) elementTag
|
|
|
|
ofType: (NSString *) aType
|
|
|
|
excluding: (NSString *) aTypeToExclude
|
|
|
|
inCard: (NGVCard *) card
|
2010-12-30 15:34:44 +01:00
|
|
|
{
|
|
|
|
NSArray *elements;
|
2011-01-11 22:21:42 +01:00
|
|
|
CardElement *ce, *found;
|
|
|
|
NSUInteger count, max;
|
2010-12-30 15:34:44 +01:00
|
|
|
|
2011-01-11 22:21:42 +01:00
|
|
|
found = nil;
|
2010-12-30 15:34:44 +01:00
|
|
|
|
2011-01-11 22:21:42 +01:00
|
|
|
elements = [[card childrenWithTag: elementTag]
|
|
|
|
cardElementsWithAttribute: @"type"
|
|
|
|
havingValue: aType];
|
|
|
|
max = [elements count];
|
|
|
|
for (count = 0; !found && count < max; count++)
|
2010-12-30 15:34:44 +01:00
|
|
|
{
|
2011-01-11 22:21:42 +01:00
|
|
|
ce = [elements objectAtIndex: count];
|
|
|
|
if (!aTypeToExclude
|
|
|
|
|| ![ce hasAttribute: @"type" havingValue: aTypeToExclude])
|
|
|
|
found = ce;
|
2010-12-30 15:34:44 +01:00
|
|
|
}
|
|
|
|
|
2011-01-11 22:21:42 +01:00
|
|
|
return found;
|
2010-12-30 15:34:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- (enum MAPISTATUS) getChildProperty: (void **) data
|
|
|
|
forKey: (NSString *) childKey
|
|
|
|
withTag: (enum MAPITAGS) proptag
|
|
|
|
{
|
2011-02-10 18:54:35 +01:00
|
|
|
NSString *stringValue, *stringValue2;
|
2010-12-30 15:34:44 +01:00
|
|
|
SOGoContactGCSEntry *child;
|
2011-01-11 22:21:42 +01:00
|
|
|
CardElement *element;
|
|
|
|
uint32_t longValue;
|
2011-02-10 18:54:35 +01:00
|
|
|
NGVCard *vCard;
|
2010-12-30 15:34:44 +01:00
|
|
|
enum MAPISTATUS rc;
|
|
|
|
|
|
|
|
rc = MAPI_E_SUCCESS;
|
|
|
|
switch (proptag)
|
|
|
|
{
|
|
|
|
case PR_ICON_INDEX: // TODO
|
|
|
|
/* see http://msdn.microsoft.com/en-us/library/cc815472.aspx */
|
|
|
|
*data = MAPILongValue (memCtx, 0x00000200);
|
|
|
|
break;
|
|
|
|
case PR_MESSAGE_CLASS_UNICODE:
|
|
|
|
*data = talloc_strdup (memCtx, "IPM.Contact");
|
|
|
|
break;
|
|
|
|
// case PR_VD_NAME_UNICODE:
|
|
|
|
// *data = talloc_strdup (memCtx, "PR_VD_NAME_UNICODE");
|
|
|
|
// break;
|
|
|
|
// case PR_EMS_AB_DXA_REMOTE_CLIENT_UNICODE: "Home:" ???
|
|
|
|
// *data = talloc_strdup (memCtx, "PR_EMS...");
|
|
|
|
// break;
|
|
|
|
case PR_OAB_NAME_UNICODE:
|
|
|
|
*data = talloc_strdup (memCtx, "PR_OAB_NAME_UNICODE");
|
|
|
|
break;
|
|
|
|
case PR_OAB_LANGID:
|
|
|
|
/* see http://msdn.microsoft.com/en-us/goglobal/bb895996.asxp */
|
|
|
|
/* English US */
|
|
|
|
*data = MAPILongValue (memCtx, 0x0409);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PR_TITLE_UNICODE:
|
|
|
|
child = [self lookupChild: childKey];
|
|
|
|
stringValue = [[child vCard] title];
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PR_COMPANY_NAME_UNICODE:
|
2011-01-11 21:24:49 +01:00
|
|
|
case PR_DEPARTMENT_NAME_UNICODE:
|
|
|
|
{
|
|
|
|
NSArray *values;
|
|
|
|
|
|
|
|
child = [self lookupChild: childKey];
|
|
|
|
values = [[child vCard] org];
|
|
|
|
stringValue = nil;
|
|
|
|
|
|
|
|
if (proptag == PR_COMPANY_NAME_UNICODE && [values count] > 0)
|
|
|
|
stringValue = [values objectAtIndex: 0];
|
|
|
|
else if (proptag == PR_DEPARTMENT_NAME_UNICODE && [values count] > 1)
|
|
|
|
stringValue = [values objectAtIndex: 1];
|
|
|
|
|
|
|
|
if (!stringValue)
|
|
|
|
stringValue = @"";
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
}
|
2010-12-30 15:34:44 +01:00
|
|
|
break;
|
|
|
|
|
2011-02-10 18:54:35 +01:00
|
|
|
case PR_SEND_INTERNET_ENCODING:
|
|
|
|
*data = MAPILongValue (memCtx, 0x00065001);
|
|
|
|
break;
|
|
|
|
|
2011-01-03 21:35:40 +01:00
|
|
|
case PR_SUBJECT_UNICODE:
|
2010-12-30 15:34:44 +01:00
|
|
|
case PR_DISPLAY_NAME_UNICODE: // Full Name
|
|
|
|
case PidLidFileUnder: // contact block title name
|
|
|
|
rc = [super getChildProperty: data
|
2011-02-08 00:19:02 +01:00
|
|
|
forKey: childKey
|
|
|
|
withTag: PR_DISPLAY_NAME_UNICODE];
|
2010-12-30 15:34:44 +01:00
|
|
|
break;
|
2011-02-10 18:54:35 +01:00
|
|
|
case PidLidFileUnderId:
|
|
|
|
*data = MAPILongValue (memCtx, 0xffffffff);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PidLidEmail1OriginalDisplayName:
|
|
|
|
case PidLidEmail1DisplayName:
|
|
|
|
child = [self lookupChild: childKey];
|
|
|
|
vCard = [child vCard];
|
|
|
|
stringValue = [vCard fn];
|
|
|
|
stringValue2 = [vCard preferredEMail];
|
|
|
|
*data = [[NSString stringWithFormat: @"%@ <%@>",
|
|
|
|
stringValue, stringValue2]
|
|
|
|
asUnicodeInMemCtx: memCtx];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PidLidEmail1EmailAddress:
|
|
|
|
case PR_ACCOUNT_UNICODE:
|
2010-12-30 15:34:44 +01:00
|
|
|
child = [self lookupChild: childKey];
|
|
|
|
stringValue = [[child vCard] preferredEMail];
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
break;
|
2011-01-14 14:13:32 +01:00
|
|
|
|
2011-02-10 18:54:35 +01:00
|
|
|
case PR_CONTACT_EMAIL_ADDRESSES_UNICODE:
|
|
|
|
child = [self lookupChild: childKey];
|
|
|
|
stringValue = [[child vCard] preferredEMail];
|
|
|
|
*data = [[NSArray arrayWithObject: stringValue]
|
|
|
|
asArrayOfUnicodeStringsInCtx: memCtx];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PR_EMS_AB_TARGET_ADDRESS_UNICODE:
|
|
|
|
child = [self lookupChild: childKey];
|
|
|
|
stringValue = [[child vCard] preferredEMail];
|
|
|
|
*data = [[NSString stringWithFormat: @"SMTP:%@", stringValue]
|
|
|
|
asUnicodeInMemCtx: memCtx];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PR_SEARCH_KEY: // TODO
|
|
|
|
child = [self lookupChild: childKey];
|
|
|
|
stringValue = [[child vCard] preferredEMail];
|
|
|
|
*data = [[stringValue dataUsingEncoding: NSASCIIStringEncoding]
|
|
|
|
asBinaryInMemCtx: memCtx];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PR_MAIL_PERMISSION:
|
|
|
|
*data = MAPIBoolValue (memCtx, YES);
|
|
|
|
break;
|
|
|
|
|
2011-01-14 14:13:32 +01:00
|
|
|
//
|
|
|
|
// TODO - same logic as -secondaryEmail in UI/Contacts/UIxContactView.m
|
|
|
|
// We should eventually merge that in order to not duplicate the code.
|
|
|
|
// We should also eventually handle PidLidEmail3OriginalDisplayName in
|
|
|
|
// SOGo, Thunderbird, etc.
|
|
|
|
//
|
2011-02-10 18:54:35 +01:00
|
|
|
case PidLidEmail2EmailAddress:
|
2011-01-14 14:13:32 +01:00
|
|
|
case PidLidEmail2OriginalDisplayName: // Other email
|
|
|
|
{
|
|
|
|
NSMutableArray *emails;
|
|
|
|
NSString *email;
|
|
|
|
NGVCard *card;
|
|
|
|
|
|
|
|
emails = [NSMutableArray array];
|
|
|
|
stringValue = nil;
|
|
|
|
|
|
|
|
card = [[self lookupChild: childKey] vCard];
|
|
|
|
[emails addObjectsFromArray: [card childrenWithTag: @"email"]];
|
|
|
|
[emails removeObjectsInArray: [card childrenWithTag: @"email"
|
|
|
|
andAttribute: @"type"
|
|
|
|
havingValue: @"pref"]];
|
|
|
|
|
|
|
|
if ([emails count] > 0)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < [emails count]; i++)
|
|
|
|
{
|
|
|
|
email = [[emails objectAtIndex: i] value: 0];
|
|
|
|
|
|
|
|
if ([email caseInsensitiveCompare: [card preferredEMail]] != NSOrderedSame)
|
|
|
|
{
|
|
|
|
stringValue = email;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!stringValue)
|
|
|
|
stringValue = @"";
|
|
|
|
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
// FIXME: this property does NOT work
|
2010-12-30 15:34:44 +01:00
|
|
|
case PR_BODY_UNICODE:
|
|
|
|
child = [self lookupChild: childKey];
|
|
|
|
stringValue = [[child vCard] note];
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PR_OFFICE_TELEPHONE_NUMBER_UNICODE:
|
|
|
|
child = [self lookupChild: childKey];
|
2011-01-14 14:13:32 +01:00
|
|
|
element = [self _element: @"tel" ofType: @"work"
|
2011-01-11 22:21:42 +01:00
|
|
|
excluding: @"fax"
|
|
|
|
inCard: [child vCard]];
|
|
|
|
if (element)
|
|
|
|
stringValue = [element value: 0];
|
|
|
|
else
|
|
|
|
stringValue = @"";
|
2010-12-30 15:34:44 +01:00
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
break;
|
|
|
|
case PR_HOME_TELEPHONE_NUMBER_UNICODE:
|
|
|
|
child = [self lookupChild: childKey];
|
2011-01-14 14:13:32 +01:00
|
|
|
element = [self _element: @"tel" ofType: @"home"
|
2011-01-11 22:21:42 +01:00
|
|
|
excluding: @"fax"
|
|
|
|
inCard: [child vCard]];
|
|
|
|
if (element)
|
|
|
|
stringValue = [element value: 0];
|
|
|
|
else
|
|
|
|
stringValue = @"";
|
2010-12-30 15:34:44 +01:00
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
break;
|
|
|
|
case PR_MOBILE_TELEPHONE_NUMBER_UNICODE:
|
|
|
|
child = [self lookupChild: childKey];
|
2011-01-14 14:13:32 +01:00
|
|
|
element = [self _element: @"tel" ofType: @"cell"
|
2011-01-11 22:21:42 +01:00
|
|
|
excluding: nil
|
|
|
|
inCard: [child vCard]];
|
|
|
|
if (element)
|
|
|
|
stringValue = [element value: 0];
|
|
|
|
else
|
|
|
|
stringValue = @"";
|
2010-12-30 15:34:44 +01:00
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
break;
|
|
|
|
case PR_PRIMARY_TELEPHONE_NUMBER_UNICODE:
|
|
|
|
child = [self lookupChild: childKey];
|
2011-01-14 14:13:32 +01:00
|
|
|
element = [self _element: @"tel" ofType: @"pref"
|
2011-01-11 22:21:42 +01:00
|
|
|
excluding: nil
|
|
|
|
inCard: [child vCard]];
|
|
|
|
if (element)
|
|
|
|
stringValue = [element value: 0];
|
|
|
|
else
|
|
|
|
stringValue = @"";
|
2010-12-30 15:34:44 +01:00
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
break;
|
|
|
|
|
2011-01-11 21:24:49 +01:00
|
|
|
case PR_BUSINESS_HOME_PAGE_UNICODE:
|
|
|
|
case PR_PERSONAL_HOME_PAGE_UNICODE:
|
|
|
|
{
|
|
|
|
NSString *type;
|
|
|
|
|
|
|
|
type = (proptag == PR_BUSINESS_HOME_PAGE_UNICODE ? @"work" : @"home");
|
|
|
|
|
|
|
|
child = [self lookupChild: childKey];
|
|
|
|
|
|
|
|
element = [self _element: @"url" ofType: type
|
|
|
|
excluding: nil
|
|
|
|
inCard: [child vCard]];
|
|
|
|
if (element)
|
|
|
|
stringValue = [element value: 0];
|
|
|
|
else
|
|
|
|
stringValue = @"";
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-12-30 15:34:44 +01:00
|
|
|
case PidLidEmail1AddressType:
|
|
|
|
case PidLidEmail2AddressType:
|
|
|
|
case PidLidEmail3AddressType:
|
|
|
|
*data = [@"SMTP" asUnicodeInMemCtx: memCtx];
|
|
|
|
break;
|
2011-01-14 14:13:32 +01:00
|
|
|
|
|
|
|
case PidLidInstantMessagingAddress:
|
|
|
|
child = [self lookupChild: childKey];
|
|
|
|
stringValue = [[[child vCard] uniqueChildWithTag: @"x-aim"] value: 0];
|
|
|
|
|
|
|
|
if (!stringValue)
|
|
|
|
stringValue = @"";
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
break;
|
2010-12-30 15:34:44 +01:00
|
|
|
|
2011-01-14 14:13:32 +01:00
|
|
|
//
|
|
|
|
// We don't handle 0x00000003 - The Other Address is the mailing address.
|
|
|
|
// See: http://msdn.microsoft.com/en-us/library/cc815430.aspx
|
|
|
|
//
|
2011-01-11 22:21:42 +01:00
|
|
|
case PidLidPostalAddressId:
|
|
|
|
child = [self lookupChild: childKey];
|
|
|
|
element = [self _element: @"adr" ofType: @"pref"
|
|
|
|
excluding: nil
|
|
|
|
inCard: [child vCard]];
|
|
|
|
if ([element hasAttribute: @"type"
|
|
|
|
havingValue: @"home"])
|
2011-01-14 14:13:32 +01:00
|
|
|
longValue = 1; // The Home Address is the mailing address.
|
2011-01-11 22:21:42 +01:00
|
|
|
else if ([element hasAttribute: @"type"
|
|
|
|
havingValue: @"work"])
|
2011-01-14 14:13:32 +01:00
|
|
|
longValue = 2; // The Work Address is the mailing address.
|
2011-01-11 22:21:42 +01:00
|
|
|
else
|
2011-01-14 14:13:32 +01:00
|
|
|
longValue = 0; // No address is selected as the mailing address.
|
2011-01-11 22:21:42 +01:00
|
|
|
*data = MAPILongValue (memCtx, longValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* preferred address */
|
|
|
|
case PR_POSTAL_ADDRESS_UNICODE:
|
|
|
|
child = [self lookupChild: childKey];
|
|
|
|
element = [self _element: @"label" ofType: @"pref"
|
|
|
|
excluding: nil
|
|
|
|
inCard: [child vCard]];
|
|
|
|
if (element)
|
|
|
|
stringValue = [element value: 0];
|
|
|
|
else
|
|
|
|
stringValue = @"";
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
break;
|
|
|
|
case PR_POST_OFFICE_BOX_UNICODE:
|
|
|
|
child = [self lookupChild: childKey];
|
|
|
|
element = [self _element: @"adr" ofType: @"pref"
|
|
|
|
excluding: nil
|
|
|
|
inCard: [child vCard]];
|
|
|
|
if (element)
|
|
|
|
stringValue = [element value: 0];
|
|
|
|
else
|
|
|
|
stringValue = @"";
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
break;
|
|
|
|
case PR_STREET_ADDRESS_UNICODE:
|
|
|
|
child = [self lookupChild: childKey];
|
|
|
|
element = [self _element: @"adr" ofType: @"pref"
|
|
|
|
excluding: nil
|
|
|
|
inCard: [child vCard]];
|
|
|
|
if (element)
|
|
|
|
stringValue = [element value: 2];
|
|
|
|
else
|
|
|
|
stringValue = @"";
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
break;
|
|
|
|
case PR_LOCALITY_UNICODE:
|
|
|
|
child = [self lookupChild: childKey];
|
|
|
|
element = [self _element: @"adr" ofType: @"pref"
|
|
|
|
excluding: nil
|
|
|
|
inCard: [child vCard]];
|
|
|
|
if (element)
|
|
|
|
stringValue = [element value: 3];
|
|
|
|
else
|
|
|
|
stringValue = @"";
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
break;
|
|
|
|
case PR_STATE_OR_PROVINCE_UNICODE:
|
|
|
|
child = [self lookupChild: childKey];
|
|
|
|
element = [self _element: @"adr" ofType: @"pref"
|
|
|
|
excluding: nil
|
|
|
|
inCard: [child vCard]];
|
|
|
|
if (element)
|
|
|
|
stringValue = [element value: 4];
|
|
|
|
else
|
|
|
|
stringValue = @"";
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
break;
|
|
|
|
case PR_POSTAL_CODE_UNICODE:
|
|
|
|
child = [self lookupChild: childKey];
|
|
|
|
element = [self _element: @"adr" ofType: @"pref"
|
|
|
|
excluding: nil
|
|
|
|
inCard: [child vCard]];
|
|
|
|
if (element)
|
|
|
|
stringValue = [element value: 5];
|
|
|
|
else
|
|
|
|
stringValue = @"";
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
break;
|
|
|
|
case PR_COUNTRY_UNICODE:
|
|
|
|
child = [self lookupChild: childKey];
|
|
|
|
element = [self _element: @"adr" ofType: @"pref"
|
|
|
|
excluding: nil
|
|
|
|
inCard: [child vCard]];
|
|
|
|
if (element)
|
|
|
|
stringValue = [element value: 6];
|
|
|
|
else
|
|
|
|
stringValue = @"";
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
break;
|
|
|
|
|
|
|
|
// case PidLidAddressCountryCode:
|
|
|
|
|
|
|
|
case PidLidWorkAddress:
|
|
|
|
child = [self lookupChild: childKey];
|
|
|
|
element = [self _element: @"label" ofType: @"work"
|
|
|
|
excluding: nil
|
|
|
|
inCard: [child vCard]];
|
|
|
|
if (element)
|
|
|
|
stringValue = [element value: 0];
|
|
|
|
else
|
|
|
|
stringValue = @"";
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PidLidWorkAddressPostOfficeBox:
|
|
|
|
child = [self lookupChild: childKey];
|
|
|
|
element = [self _element: @"adr" ofType: @"work"
|
|
|
|
excluding: nil
|
|
|
|
inCard: [child vCard]];
|
|
|
|
if (element)
|
|
|
|
stringValue = [element value: 0];
|
|
|
|
else
|
|
|
|
stringValue = @"";
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
break;
|
|
|
|
case PidLidWorkAddressStreet:
|
|
|
|
child = [self lookupChild: childKey];
|
|
|
|
element = [self _element: @"adr" ofType: @"work"
|
|
|
|
excluding: nil
|
|
|
|
inCard: [child vCard]];
|
|
|
|
if (element)
|
|
|
|
stringValue = [element value: 2];
|
|
|
|
else
|
|
|
|
stringValue = @"";
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
break;
|
|
|
|
case PidLidWorkAddressCity:
|
|
|
|
child = [self lookupChild: childKey];
|
|
|
|
element = [self _element: @"adr" ofType: @"work"
|
|
|
|
excluding: nil
|
|
|
|
inCard: [child vCard]];
|
|
|
|
if (element)
|
|
|
|
stringValue = [element value: 3];
|
|
|
|
else
|
|
|
|
stringValue = @"";
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
break;
|
|
|
|
case PidLidWorkAddressState:
|
|
|
|
child = [self lookupChild: childKey];
|
|
|
|
element = [self _element: @"adr" ofType: @"work"
|
|
|
|
excluding: nil
|
|
|
|
inCard: [child vCard]];
|
|
|
|
if (element)
|
|
|
|
stringValue = [element value: 4];
|
|
|
|
else
|
|
|
|
stringValue = @"";
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
break;
|
|
|
|
case PidLidWorkAddressPostalCode:
|
|
|
|
child = [self lookupChild: childKey];
|
|
|
|
element = [self _element: @"adr" ofType: @"work"
|
|
|
|
excluding: nil
|
|
|
|
inCard: [child vCard]];
|
|
|
|
if (element)
|
|
|
|
stringValue = [element value: 5];
|
|
|
|
else
|
|
|
|
stringValue = @"";
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
break;
|
|
|
|
case PidLidWorkAddressCountry:
|
|
|
|
child = [self lookupChild: childKey];
|
|
|
|
element = [self _element: @"adr" ofType: @"work"
|
|
|
|
excluding: nil
|
|
|
|
inCard: [child vCard]];
|
|
|
|
if (element)
|
|
|
|
stringValue = [element value: 6];
|
|
|
|
else
|
|
|
|
stringValue = @"";
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
break;
|
|
|
|
|
2011-01-14 14:13:32 +01:00
|
|
|
// PidTagNickname
|
2011-01-11 21:24:49 +01:00
|
|
|
case PR_NICKNAME_UNICODE:
|
|
|
|
child = [self lookupChild: childKey];
|
|
|
|
stringValue = [[child vCard] nickname];
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
break;
|
|
|
|
|
2011-01-14 14:13:32 +01:00
|
|
|
case PR_BIRTHDAY:
|
|
|
|
{
|
|
|
|
NSCalendarDate *dateValue;
|
|
|
|
|
|
|
|
child = [self lookupChild: childKey];
|
|
|
|
|
|
|
|
stringValue = [[child vCard] bday];
|
|
|
|
|
|
|
|
if (stringValue)
|
|
|
|
{
|
|
|
|
dateValue = [NSCalendarDate dateWithString: stringValue
|
|
|
|
calendarFormat: @"%Y-%m-%d"];
|
|
|
|
// FIXME: We add a day, otherwise Outlook 2003 will display at day earlier
|
|
|
|
dateValue = [dateValue addYear: 0 month: 0 day: 1 hour: 0 minute: 0 second: 0];
|
|
|
|
*data = [dateValue asFileTimeInMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
rc = MAPI_E_NOT_FOUND;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-12-30 15:34:44 +01:00
|
|
|
default:
|
|
|
|
rc = [super getChildProperty: data
|
|
|
|
forKey: childKey
|
|
|
|
withTag: proptag];
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) backendIdentifierForProperty: (enum MAPITAGS) property
|
|
|
|
{
|
|
|
|
static NSMutableDictionary *knownProperties = nil;
|
|
|
|
|
|
|
|
if (!knownProperties)
|
|
|
|
{
|
|
|
|
knownProperties = [NSMutableDictionary new];
|
|
|
|
[knownProperties setObject: @"c_mail"
|
|
|
|
forKey: MAPIPropertyKey (PidLidEmail1EmailAddress)];
|
|
|
|
[knownProperties setObject: @"c_mail"
|
|
|
|
forKey: MAPIPropertyKey (PidLidEmail2EmailAddress)];
|
|
|
|
[knownProperties setObject: @"c_mail"
|
|
|
|
forKey: MAPIPropertyKey (PidLidEmail3EmailAddress)];
|
|
|
|
[knownProperties setObject: @"c_cn"
|
|
|
|
forKey: MAPIPropertyKey (PR_DISPLAY_NAME_UNICODE)];
|
2011-02-11 17:09:42 +01:00
|
|
|
[knownProperties setObject: @"c_cn"
|
|
|
|
forKey: MAPIPropertyKey (PidLidFileUnder)];
|
2010-12-30 15:34:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return [knownProperties objectForKey: MAPIPropertyKey (property)];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* restrictions */
|
|
|
|
|
|
|
|
- (MAPIRestrictionState) evaluatePropertyRestriction: (struct mapi_SPropertyRestriction *) res
|
|
|
|
intoQualifier: (EOQualifier **) qualifier
|
|
|
|
{
|
|
|
|
MAPIRestrictionState rc;
|
|
|
|
id value;
|
|
|
|
|
|
|
|
value = NSObjectFromMAPISPropValue (&res->lpProp);
|
|
|
|
switch (res->ulPropTag)
|
|
|
|
{
|
|
|
|
case PR_MESSAGE_CLASS_UNICODE:
|
|
|
|
if ([value isEqualToString: @"IPM.Contact"])
|
|
|
|
rc = MAPIRestrictionStateAlwaysTrue;
|
|
|
|
else
|
|
|
|
rc = MAPIRestrictionStateAlwaysFalse;
|
|
|
|
break;
|
|
|
|
case PidLidEmail1AddressType:
|
|
|
|
case PidLidEmail2AddressType:
|
|
|
|
case PidLidEmail3AddressType:
|
|
|
|
if ([value isEqualToString: @"SMTP"])
|
|
|
|
rc = MAPIRestrictionStateAlwaysTrue;
|
|
|
|
else
|
|
|
|
rc = MAPIRestrictionStateAlwaysFalse;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
rc = [super evaluatePropertyRestriction: res intoQualifier: qualifier];
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-02-11 17:09:42 +01:00
|
|
|
/* sorting */
|
|
|
|
|
|
|
|
- (NSString *) sortIdentifierForProperty: (enum MAPITAGS) property
|
|
|
|
{
|
|
|
|
static NSMutableDictionary *knownProperties = nil;
|
|
|
|
|
|
|
|
if (!knownProperties)
|
|
|
|
{
|
|
|
|
knownProperties = [NSMutableDictionary new];
|
|
|
|
[knownProperties setObject: @"c_cn"
|
|
|
|
forKey: MAPIPropertyKey (PidLidFileUnder)];
|
|
|
|
}
|
|
|
|
|
|
|
|
return [knownProperties objectForKey: MAPIPropertyKey (property)];
|
|
|
|
}
|
|
|
|
|
2010-12-30 15:34:44 +01:00
|
|
|
@end
|