Monotone-Parent: 044ebf928befcb199e07d3b192460518361eb827

Monotone-Revision: 94c9fbf7703f8bdb98dae4ab4791e27a4d07d72a

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2011-01-11T21:21:42
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
Wolfgang Sourdeau 2011-01-11 21:21:42 +00:00
parent d82adbceca
commit 218712bc0f
2 changed files with 239 additions and 44 deletions

View File

@ -1,5 +1,19 @@
2011-01-11 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* OpenChange/MAPIStoreContactsMessageTable.m
(-_element:ofType:excluding:inCard:): new version of the previous
-_phoneOfType:excluding:inCard: method, which now returns the
requested element rather than it's first value and which enables
the specification of the tag.
(-getChildProperty:forKey:withTag:): added support for
PidLidPostalAddressId, PR_POSTAL_ADDRESS_UNICODE,
PR_POST_OFFICE_BOX_UNICODE, PR_STREET_ADDRESS_UNICODE,
PR_LOCALITY_UNICODE, PR_STATE_OR_PROVINCE_UNICODE,
PR_POSTAL_CODE_UNICODE, PR_COUNTRY_UNICODE, PidLidWorkAddress,
PidLidWorkAddressPostOfficeBox, PidLidWorkAddressStreet,
PidLidWorkAddressCity, PidLidWorkAddressState,
PidLidWorkAddressPostalCode and PidLidWorkAddressCountry.
* OpenChange/MAPIStoreContext.m (-openMessage:forKey:inTable:):
avoid taking NULL values into account when returning the basic
properties.

View File

@ -53,45 +53,30 @@
return componentQualifier;
}
- (NSString *) _phoneOfType: (NSString *) aType
excluding: (NSString *) aTypeToExclude
inCard: (NGVCard *) card
- (CardElement *) _element: (NSString *) elementTag
ofType: (NSString *) aType
excluding: (NSString *) aTypeToExclude
inCard: (NGVCard *) card
{
NSArray *elements;
NSArray *phones;
NSString *phone;
CardElement *ce, *found;
NSUInteger count, max;
phones = [card childrenWithTag: @"tel"];
found = nil;
elements = [phones cardElementsWithAttribute: @"type"
havingValue: aType];
phone = nil;
if ([elements count] > 0)
elements = [[card childrenWithTag: elementTag]
cardElementsWithAttribute: @"type"
havingValue: aType];
max = [elements count];
for (count = 0; !found && count < max; count++)
{
CardElement *ce;
int i;
for (i = 0; i < [elements count]; i++)
{
ce = [elements objectAtIndex: i];
phone = [ce value: 0];
if (!aTypeToExclude)
break;
if (![ce hasAttribute: @"type" havingValue: aTypeToExclude])
break;
phone = nil;
}
ce = [elements objectAtIndex: count];
if (!aTypeToExclude
|| ![ce hasAttribute: @"type" havingValue: aTypeToExclude])
found = ce;
}
if (!phone)
phone = @"";
return phone;
return found;
}
- (enum MAPISTATUS) getChildProperty: (void **) data
@ -100,6 +85,8 @@
{
NSString *stringValue;
SOGoContactGCSEntry *child;
CardElement *element;
uint32_t longValue;
enum MAPISTATUS rc;
rc = MAPI_E_SUCCESS;
@ -137,6 +124,8 @@
child = [self lookupChild: childKey];
/* that's buggy but it's for the demo */
stringValue = [[[child vCard] org] componentsJoinedByString: @", "];
if (!stringValue)
stringValue = @"";
*data = [stringValue asUnicodeInMemCtx: memCtx];
break;
@ -160,30 +149,46 @@
case PR_OFFICE_TELEPHONE_NUMBER_UNICODE:
child = [self lookupChild: childKey];
stringValue = [self _phoneOfType: @"work"
excluding: @"fax"
inCard: [child vCard]];
element = [self _element: @"phone" ofType: @"work"
excluding: @"fax"
inCard: [child vCard]];
if (element)
stringValue = [element value: 0];
else
stringValue = @"";
*data = [stringValue asUnicodeInMemCtx: memCtx];
break;
case PR_HOME_TELEPHONE_NUMBER_UNICODE:
child = [self lookupChild: childKey];
stringValue = [self _phoneOfType: @"home"
excluding: @"fax"
inCard: [child vCard]];
element = [self _element: @"phone" ofType: @"home"
excluding: @"fax"
inCard: [child vCard]];
if (element)
stringValue = [element value: 0];
else
stringValue = @"";
*data = [stringValue asUnicodeInMemCtx: memCtx];
break;
case PR_MOBILE_TELEPHONE_NUMBER_UNICODE:
child = [self lookupChild: childKey];
stringValue = [self _phoneOfType: @"cell"
excluding: nil
inCard: [child vCard]];
element = [self _element: @"phone" ofType: @"cell"
excluding: nil
inCard: [child vCard]];
if (element)
stringValue = [element value: 0];
else
stringValue = @"";
*data = [stringValue asUnicodeInMemCtx: memCtx];
break;
case PR_PRIMARY_TELEPHONE_NUMBER_UNICODE:
child = [self lookupChild: childKey];
stringValue = [self _phoneOfType: @"pref"
excluding: nil
inCard: [child vCard]];
element = [self _element: @"phone" ofType: @"pref"
excluding: nil
inCard: [child vCard]];
if (element)
stringValue = [element value: 0];
else
stringValue = @"";
*data = [stringValue asUnicodeInMemCtx: memCtx];
break;
@ -193,6 +198,182 @@
*data = [@"SMTP" asUnicodeInMemCtx: memCtx];
break;
case PidLidPostalAddressId:
child = [self lookupChild: childKey];
element = [self _element: @"adr" ofType: @"pref"
excluding: nil
inCard: [child vCard]];
if ([element hasAttribute: @"type"
havingValue: @"home"])
longValue = 1;
else if ([element hasAttribute: @"type"
havingValue: @"work"])
longValue = 2;
else
longValue = 0;
*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;
default:
rc = [super getChildProperty: data
forKey: childKey