From 006da94bd52504b3b75944bf114dc7473b00d8d4 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Mon, 10 Jan 2011 18:47:12 +0000 Subject: [PATCH 01/14] Monotone-Parent: bc5478c6da74ce0487be5bc0045ffb55f4ff5297 Monotone-Revision: cb5cc3133ac0a2327dd3cc8408ecc03e59d08d44 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-01-10T18:47:12 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 5 +++++ OpenChange/MAPIStoreContext.m | 18 ------------------ 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 67ea08d68..8dd1fefdf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-10 Wolfgang Sourdeau + + * OpenChange/MAPIStoreContext.m (-typeLessTag:): removed method as + types are now determined from openchange core. + 2011-01-07 Wolfgang Sourdeau * OpenChange/MAPIStoreContext.m (_typeLessTag:): new method diff --git a/OpenChange/MAPIStoreContext.m b/OpenChange/MAPIStoreContext.m index f072ad9bc..e8b8bf841 100644 --- a/OpenChange/MAPIStoreContext.m +++ b/OpenChange/MAPIStoreContext.m @@ -1002,22 +1002,6 @@ _prepareContextClass (struct mapistore_context *newMemCtx, save: NO]; } -- (enum MAPITAGS) _typeLessTag: (enum MAPITAGS) tag -{ - if (tag == 0x300b0000) - tag = PR_SEARCH_KEY; - else if (tag == 0x30070000) - tag = PR_CREATION_TIME; - else if (tag == 0x30080000) - tag = PR_LAST_MODIFICATION_TIME; - else if (tag == 0x0e080000) - tag = PR_MESSAGE_SIZE; - else - [self warnWithFormat: @"unknown typeless tag: 0x%.8x", tag]; - - return tag; -} - - (int) getProperties: (struct SPropTagArray *) sPropTagArray ofTableType: (uint8_t) tableType inRow: (struct SRow *) aRow @@ -1056,8 +1040,6 @@ _prepareContextClass (struct mapistore_context *newMemCtx, for (count = 0; count < sPropTagArray->cValues; count++) { tag = sPropTagArray->aulPropTag[count]; - if ((tag & 0x0000ffff) == 0) - tag = [self _typeLessTag: tag]; propValue = NULL; propRc = [table getChildProperty: &propValue From a15f06c844457bdcc28ddab83d59ddc940518d93 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 11 Jan 2011 17:18:11 +0000 Subject: [PATCH 02/14] Monotone-Parent: cb5cc3133ac0a2327dd3cc8408ecc03e59d08d44 Monotone-Revision: 9466acabd40c4707e1c9468170d5b231345d8cf9 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-01-11T17:18:11 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 5 +++ OpenChange/SOGoContactGCSEntry+MAPIStore.m | 38 ++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/ChangeLog b/ChangeLog index 8dd1fefdf..9785e22de 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-11 Wolfgang Sourdeau + + * OpenChange/SOGoContactGCSEntry+MAPIStore.m + (-setMAPIProperties:): added support for work address. + 2011-01-10 Wolfgang Sourdeau * OpenChange/MAPIStoreContext.m (-typeLessTag:): removed method as diff --git a/OpenChange/SOGoContactGCSEntry+MAPIStore.m b/OpenChange/SOGoContactGCSEntry+MAPIStore.m index 9a3b78ff6..ebd6fe59d 100644 --- a/OpenChange/SOGoContactGCSEntry+MAPIStore.m +++ b/OpenChange/SOGoContactGCSEntry+MAPIStore.m @@ -20,6 +20,7 @@ * Boston, MA 02111-1307, USA. */ +#import #import #import #import @@ -38,6 +39,8 @@ - (void) setMAPIProperties: (NSDictionary *) properties { NGVCard *newCard, *oldCard; + NSArray *addresses; + CardElement *adr; id value; [self logWithFormat: @"setMAPIProperties: %@", properties]; @@ -66,6 +69,41 @@ if (value) [newCard addEmail: value types: nil]; + /* 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]; + ASSIGN (content, [newCard versitString]); } From 3c7d44df080b3c24b168a4b9f6f7aaeb44c655e4 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 11 Jan 2011 21:16:31 +0000 Subject: [PATCH 03/14] Monotone-Parent: 9466acabd40c4707e1c9468170d5b231345d8cf9 Monotone-Revision: cf5ca218da1c1ff34ff78091ca6ef9e4d34fdfb3 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-01-11T21:16:31 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 5 +- OpenChange/SOGoContactGCSEntry+MAPIStore.m | 61 ++++++++++++++++------ 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9785e22de..ac74fd60f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,10 @@ 2011-01-11 Wolfgang Sourdeau * OpenChange/SOGoContactGCSEntry+MAPIStore.m - (-setMAPIProperties:): added support for work address. + (-setMAPIProperties:): added support for work address and its + corresponding addresse label. Preliminary support for + "PidLidPostalAddressId" which enables us to set a certain address + as preferred. 2011-01-10 Wolfgang Sourdeau diff --git a/OpenChange/SOGoContactGCSEntry+MAPIStore.m b/OpenChange/SOGoContactGCSEntry+MAPIStore.m index ebd6fe59d..159970a70 100644 --- a/OpenChange/SOGoContactGCSEntry+MAPIStore.m +++ b/OpenChange/SOGoContactGCSEntry+MAPIStore.m @@ -39,8 +39,9 @@ - (void) setMAPIProperties: (NSDictionary *) properties { NGVCard *newCard, *oldCard; - NSArray *addresses; - CardElement *adr; + NSArray *elements; + CardElement *element; + int postalAddressId; id value; [self logWithFormat: @"setMAPIProperties: %@", properties]; @@ -69,40 +70,68 @@ if (value) [newCard addEmail: value types: nil]; + postalAddressId = [[properties objectForKey: MAPIPropertyKey (PidLidPostalAddressId)] + intValue]; + /* Work address */ - addresses = [newCard childrenWithTag: @"adr" + value = [properties objectForKey: MAPIPropertyKey (PidLidWorkAddress)]; + if ([value length]) + { + elements = [newCard childrenWithTag: @"label" + andAttribute: @"type" + havingValue: @"work"]; + if ([elements count] > 0) + { + element = [elements objectAtIndex: 0]; + [element setValues: nil]; + } + else + { + element = [CardElement elementWithTag: @"label"]; + [element addAttribute: @"type" value: @"work"]; + [card addChild: element]; + } + if (postalAddressId == 2) + [element addAttribute: @"type" + value: @"pref"]; + [element setValue: 0 to: value]; + } + + elements = [newCard childrenWithTag: @"adr" andAttribute: @"type" havingValue: @"work"]; - if ([addresses count] > 0) + if ([elements count] > 0) { - adr = [addresses objectAtIndex: 0]; - [adr setValues: nil]; + element = [elements objectAtIndex: 0]; + [element setValues: nil]; } else { - adr = [CardElement elementWithTag: @"adr"]; - [adr addAttribute: @"type" value: @"work"]; - [card addChild: adr]; + element = [CardElement elementWithTag: @"adr"]; + [element addAttribute: @"type" value: @"work"]; + [card addChild: element]; } - + if (postalAddressId == 2) + [element addAttribute: @"type" + value: @"pref"]; value = [properties objectForKey: MAPIPropertyKey (PidLidWorkAddressPostOfficeBox)]; if (value) - [adr setValue: 0 to: value]; + [element setValue: 0 to: value]; value = [properties objectForKey: MAPIPropertyKey (PidLidWorkAddressStreet)]; if (value) - [adr setValue: 2 to: value]; + [element setValue: 2 to: value]; value = [properties objectForKey: MAPIPropertyKey (PidLidWorkAddressCity)]; if (value) - [adr setValue: 3 to: value]; + [element setValue: 3 to: value]; value = [properties objectForKey: MAPIPropertyKey (PidLidWorkAddressState)]; if (value) - [adr setValue: 4 to: value]; + [element setValue: 4 to: value]; value = [properties objectForKey: MAPIPropertyKey (PidLidWorkAddressPostalCode)]; if (value) - [adr setValue: 5 to: value]; + [element setValue: 5 to: value]; value = [properties objectForKey: MAPIPropertyKey (PidLidWorkAddressCountry)]; if (value) - [adr setValue: 6 to: value]; + [element setValue: 6 to: value]; ASSIGN (content, [newCard versitString]); } From d82adbceca2ab9f9a727eaccdb22cce4deb4bf60 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 11 Jan 2011 21:17:52 +0000 Subject: [PATCH 04/14] Monotone-Parent: cf5ca218da1c1ff34ff78091ca6ef9e4d34fdfb3 Monotone-Revision: 044ebf928befcb199e07d3b192460518361eb827 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-01-11T21:17:52 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 4 ++++ OpenChange/MAPIStoreContext.m | 12 +++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index ac74fd60f..9acf1b60a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2011-01-11 Wolfgang Sourdeau + * OpenChange/MAPIStoreContext.m (-openMessage:forKey:inTable:): + avoid taking NULL values into account when returning the basic + properties. + * OpenChange/SOGoContactGCSEntry+MAPIStore.m (-setMAPIProperties:): added support for work address and its corresponding addresse label. Preliminary support for diff --git a/OpenChange/MAPIStoreContext.m b/OpenChange/MAPIStoreContext.m index e8b8bf841..499758b67 100644 --- a/OpenChange/MAPIStoreContext.m +++ b/OpenChange/MAPIStoreContext.m @@ -803,11 +803,13 @@ _prepareContextClass (struct mapistore_context *newMemCtx, @" returned for proptag %s(0x%.8x)", propName, tags[count]]; } - - set_SPropValue_proptag (properties->lpProps + properties->cValues, - tags[count], - propValue); - properties->cValues++; + else + { + set_SPropValue_proptag (properties->lpProps + properties->cValues, + tags[count], + propValue); + properties->cValues++; + } } } msg->properties = properties; From 218712bc0f7a22eb679074d88ca02e88ea4d8557 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 11 Jan 2011 21:21:42 +0000 Subject: [PATCH 05/14] Monotone-Parent: 044ebf928befcb199e07d3b192460518361eb827 Monotone-Revision: 94c9fbf7703f8bdb98dae4ab4791e27a4d07d72a Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-01-11T21:21:42 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 14 ++ OpenChange/MAPIStoreContactsMessageTable.m | 269 +++++++++++++++++---- 2 files changed, 239 insertions(+), 44 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9acf1b60a..987f6cecc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,19 @@ 2011-01-11 Wolfgang Sourdeau + * 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. diff --git a/OpenChange/MAPIStoreContactsMessageTable.m b/OpenChange/MAPIStoreContactsMessageTable.m index f7f847d1a..f173037b4 100644 --- a/OpenChange/MAPIStoreContactsMessageTable.m +++ b/OpenChange/MAPIStoreContactsMessageTable.m @@ -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 From 2c7f2a4c480624286b6db96f112a203fbc7b9c58 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Tue, 11 Jan 2011 20:24:49 +0000 Subject: [PATCH 06/14] See ChangeLog Monotone-Parent: 94c9fbf7703f8bdb98dae4ab4791e27a4d07d72a Monotone-Revision: b917b1533c38a1f8ebf599d2f181801de2e29599 Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2011-01-11T20:24:49 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 6 +++ OpenChange/MAPIStoreContactsMessageTable.m | 50 +++++++++++++++++++--- UI/Scheduler/UIxComponentEditor.m | 4 +- 3 files changed, 52 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 987f6cecc..5ff9c0b4a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-11 Ludovic Marcotte + + * OpenChange/MAPIStoreContactsMessageTable.m + Added more properties: home/work URL, nickname + and department. + 2011-01-11 Wolfgang Sourdeau * OpenChange/MAPIStoreContactsMessageTable.m diff --git a/OpenChange/MAPIStoreContactsMessageTable.m b/OpenChange/MAPIStoreContactsMessageTable.m index f173037b4..c4dd5ffe6 100644 --- a/OpenChange/MAPIStoreContactsMessageTable.m +++ b/OpenChange/MAPIStoreContactsMessageTable.m @@ -121,12 +121,23 @@ break; case PR_COMPANY_NAME_UNICODE: - 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]; + 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]; + } break; case PR_SUBJECT_UNICODE: @@ -192,6 +203,26 @@ *data = [stringValue asUnicodeInMemCtx: memCtx]; break; + 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; + case PidLidEmail1AddressType: case PidLidEmail2AddressType: case PidLidEmail3AddressType: @@ -374,6 +405,13 @@ *data = [stringValue asUnicodeInMemCtx: memCtx]; break; + // PidTagNickname + case PR_NICKNAME_UNICODE: + child = [self lookupChild: childKey]; + stringValue = [[child vCard] nickname]; + *data = [stringValue asUnicodeInMemCtx: memCtx]; + break; + default: rc = [super getChildProperty: data forKey: childKey diff --git a/UI/Scheduler/UIxComponentEditor.m b/UI/Scheduler/UIxComponentEditor.m index 6c44fda8c..891796575 100644 --- a/UI/Scheduler/UIxComponentEditor.m +++ b/UI/Scheduler/UIxComponentEditor.m @@ -1253,9 +1253,9 @@ iRANGE(2); currentOwnerIdentity = [currentUser defaultIdentity]; currentOwnerProfile = [NSMutableDictionary dictionary]; - [currentOwnerProfile setObject: [currentOwnerIdentity objectForKey: @"fullName"] + [currentOwnerProfile setObject: ([currentOwnerIdentity objectForKey: @"fullName"] == nil ? @"" : [currentOwnerIdentity objectForKey: @"fullName"]) forKey: @"name"]; - [currentOwnerProfile setObject: [currentOwnerIdentity objectForKey: @"email"] + [currentOwnerProfile setObject: ([currentOwnerIdentity objectForKey: @"email"] == nil ? @"" : [currentOwnerIdentity objectForKey: @"email"]) forKey: @"email"]; [currentOwnerProfile setObject: @"accepted" forKey: @"partstat"]; From 91fe9abd50ddbd3b9d057e002f13839f20672aaa Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 11 Jan 2011 23:07:41 +0000 Subject: [PATCH 07/14] Monotone-Parent: b917b1533c38a1f8ebf599d2f181801de2e29599 Monotone-Revision: 387d4024d17f365f108803c45c8199af49497950 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-01-11T23:07:41 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 6 +++++- OpenChange/MAPIStoreContext.m | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5ff9c0b4a..8407cb06d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,11 +1,15 @@ 2011-01-11 Ludovic Marcotte * OpenChange/MAPIStoreContactsMessageTable.m - Added more properties: home/work URL, nickname + Added more properties: home/work URL, nickname and department. 2011-01-11 Wolfgang Sourdeau + * OpenChange/MAPIStoreContext.m (-openMessage:withMID:inFID:): + create a message dictionary in the message cache in order to + enable modifications. + * OpenChange/MAPIStoreContactsMessageTable.m (-_element:ofType:excluding:inCard:): new version of the previous -_phoneOfType:excluding:inCard: method, which now returns the diff --git a/OpenChange/MAPIStoreContext.m b/OpenChange/MAPIStoreContext.m index 499758b67..29ff9e372 100644 --- a/OpenChange/MAPIStoreContext.m +++ b/OpenChange/MAPIStoreContext.m @@ -824,6 +824,7 @@ _prepareContextClass (struct mapistore_context *newMemCtx, NSString *childURL, *childKey, *folderURL; MAPIStoreTable *table; int rc; + BOOL isAssociated; childURL = [mapping urlFromID: mid]; if (childURL) @@ -832,9 +833,13 @@ _prepareContextClass (struct mapistore_context *newMemCtx, andFolderURLAt: &folderURL]; table = [self _tableForFID: fid andTableType: MAPISTORE_FAI_TABLE]; if ([[table cachedChildKeys] containsObject: childKey]) - rc = [self openMessage: msg forKey: childKey inTable: table]; + { + isAssociated = YES; + rc = [self openMessage: msg forKey: childKey inTable: table]; + } else { + isAssociated = NO; table = [self _tableForFID: fid andTableType: MAPISTORE_MESSAGE_TABLE]; if ([[table cachedChildKeys] containsObject: childKey]) rc = [self openMessage: msg forKey: childKey inTable: table]; @@ -845,6 +850,11 @@ _prepareContextClass (struct mapistore_context *newMemCtx, else rc = MAPISTORE_ERR_NOT_FOUND; + if (rc == MAPI_E_SUCCESS) + [self createMessagePropertiesWithMID: mid + inFID: fid + isAssociated: isAssociated]; + return rc; } @@ -1168,7 +1178,7 @@ _prepareContextClass (struct mapistore_context *newMemCtx, [self logWithFormat: @"fmid 0x%.16x found", fmid]; for (counter = 0; counter < aRow->cValues; counter++) { - cValue = &(aRow->lpProps[counter]); + cValue = aRow->lpProps + counter; [message setObject: NSObjectFromSPropValue (cValue) forKey: MAPIPropertyKey (cValue->ulPropTag)]; } From 806916688361e35c2c3d4aca788c92328483d735 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 11 Jan 2011 23:08:36 +0000 Subject: [PATCH 08/14] Monotone-Parent: 387d4024d17f365f108803c45c8199af49497950 Monotone-Revision: 0889f44ef075162f639e073a81781dfd866bbc41 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-01-11T23:08:36 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 6 +++ OpenChange/SOGoContactGCSEntry+MAPIStore.m | 62 +++++++++++++--------- 2 files changed, 43 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8407cb06d..4973b75e2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-11 Wolfgang Sourdeau + + * OpenChange/SOGoContactGCSEntry+MAPIStore.m (-setMAPIProperties): + carefully existing handled fields to avoid removing them during + modification. + 2011-01-11 Ludovic Marcotte * OpenChange/MAPIStoreContactsMessageTable.m diff --git a/OpenChange/SOGoContactGCSEntry+MAPIStore.m b/OpenChange/SOGoContactGCSEntry+MAPIStore.m index 159970a70..be576ace7 100644 --- a/OpenChange/SOGoContactGCSEntry+MAPIStore.m +++ b/OpenChange/SOGoContactGCSEntry+MAPIStore.m @@ -38,7 +38,7 @@ - (void) setMAPIProperties: (NSDictionary *) properties { - NGVCard *newCard, *oldCard; + NGVCard *newCard; NSArray *elements; CardElement *element; int postalAddressId; @@ -46,16 +46,7 @@ [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 = [self vCard]; [newCard setTag: @"vcard"]; [newCard setVersion: @"3.0"]; [newCard setProdID: @"-//Inverse inc.//OpenChange+SOGo//EN"]; @@ -66,9 +57,32 @@ if (value) [newCard setFn: value]; + elements = [newCard childrenWithTag: @"email"]; value = [properties objectForKey: MAPIPropertyKey (PidLidEmail1EmailAddress)]; if (value) - [newCard addEmail: value types: nil]; + { + if ([elements count] > 0) + [[elements objectAtIndex: 0] setValue: 0 to: value]; + else + [newCard addEmail: value + types: [NSArray arrayWithObject: @"pref"]]; + } + value = [properties objectForKey: MAPIPropertyKey (PidLidEmail2EmailAddress)]; + if (value) + { + if ([elements count] > 1) + [[elements objectAtIndex: 1] setValue: 0 to: value]; + else + [newCard addEmail: value types: nil]; + } + value = [properties objectForKey: MAPIPropertyKey (PidLidEmail3EmailAddress)]; + if (value) + { + if ([elements count] > 2) + [[elements objectAtIndex: 2] setValue: 0 to: value]; + else + [newCard addEmail: value types: nil]; + } postalAddressId = [[properties objectForKey: MAPIPropertyKey (PidLidPostalAddressId)] intValue]; @@ -81,10 +95,7 @@ andAttribute: @"type" havingValue: @"work"]; if ([elements count] > 0) - { - element = [elements objectAtIndex: 0]; - [element setValues: nil]; - } + element = [elements objectAtIndex: 0]; else { element = [CardElement elementWithTag: @"label"]; @@ -92,19 +103,20 @@ [card addChild: element]; } if (postalAddressId == 2) - [element addAttribute: @"type" - value: @"pref"]; + { + [element removeValue: @"pref" + fromAttribute: @"type"]; + [element addAttribute: @"type" + value: @"pref"]; + } [element setValue: 0 to: value]; } elements = [newCard childrenWithTag: @"adr" - andAttribute: @"type" - havingValue: @"work"]; + andAttribute: @"type" + havingValue: @"work"]; if ([elements count] > 0) - { - element = [elements objectAtIndex: 0]; - [element setValues: nil]; - } + element = [elements objectAtIndex: 0]; else { element = [CardElement elementWithTag: @"adr"]; @@ -113,7 +125,7 @@ } if (postalAddressId == 2) [element addAttribute: @"type" - value: @"pref"]; + value: @"pref"]; value = [properties objectForKey: MAPIPropertyKey (PidLidWorkAddressPostOfficeBox)]; if (value) [element setValue: 0 to: value]; From c78206d6786ec85053664ccfb75e2f889b5d47bf Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 11 Jan 2011 23:08:58 +0000 Subject: [PATCH 09/14] Monotone-Parent: 0889f44ef075162f639e073a81781dfd866bbc41 Monotone-Revision: e198027d57649c8c9df73ce499a03bd20def6857 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-01-11T23:08:58 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4973b75e2..9b4a6988d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,3 @@ -2011-01-11 Wolfgang Sourdeau - - * OpenChange/SOGoContactGCSEntry+MAPIStore.m (-setMAPIProperties): - carefully existing handled fields to avoid removing them during - modification. - 2011-01-11 Ludovic Marcotte * OpenChange/MAPIStoreContactsMessageTable.m @@ -39,6 +33,8 @@ corresponding addresse label. Preliminary support for "PidLidPostalAddressId" which enables us to set a certain address as preferred. + Carefully replace existing handled fields to avoid removing them + during modification. 2011-01-10 Wolfgang Sourdeau From 8785f4e7b88a35753bef4ad0c684c34ddd1347ce Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 11 Jan 2011 23:30:53 +0000 Subject: [PATCH 10/14] Monotone-Parent: e198027d57649c8c9df73ce499a03bd20def6857 Monotone-Revision: cf5dbcfeb54d6ec004ff08361ffb854966336b90 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-01-11T23:30:53 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 4 ++++ OpenChange/MAPIStoreTasksMessageTable.m | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 9b4a6988d..bf550373a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,10 @@ 2011-01-11 Wolfgang Sourdeau + * OpenChange/MAPIStoreTasksMessageTable.m + (-getChildProperty:forKey:withTag:): fixed typo affecting + PidLidTaskStatus. + * OpenChange/MAPIStoreContext.m (-openMessage:withMID:inFID:): create a message dictionary in the message cache in order to enable modifications. diff --git a/OpenChange/MAPIStoreTasksMessageTable.m b/OpenChange/MAPIStoreTasksMessageTable.m index f021879ad..0c7547a39 100644 --- a/OpenChange/MAPIStoreTasksMessageTable.m +++ b/OpenChange/MAPIStoreTasksMessageTable.m @@ -132,7 +132,7 @@ task = [[self lookupChild: childKey] component: NO secure: NO]; status = [task status]; if (![status length] - || [status isEqualToString: @"NEEDS-ACTIONS"]) + || [status isEqualToString: @"NEEDS-ACTION"]) statusValue = 0; else if ([status isEqualToString: @"IN-PROCESS"]) statusValue = 1; From 60ace1381cd9b91d53fbb7ffba2019424867ad59 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 12 Jan 2011 00:07:05 +0000 Subject: [PATCH 11/14] Monotone-Parent: cf5dbcfeb54d6ec004ff08361ffb854966336b90 Monotone-Revision: 454eba06ab9f1fc198036d0eab58db1a689f60ed Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-01-12T00:07:05 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 3 +++ OpenChange/MAPIStoreTable.m | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index bf550373a..cc13abb17 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,9 @@ 2011-01-11 Wolfgang Sourdeau + * OpenChange/MAPIStoreTable.m (-cleanupCaches): remove lastChild + from cache too. + * OpenChange/MAPIStoreTasksMessageTable.m (-getChildProperty:forKey:withTag:): fixed typo affecting PidLidTaskStatus. diff --git a/OpenChange/MAPIStoreTable.m b/OpenChange/MAPIStoreTable.m index 3bff46999..bc46f9496 100644 --- a/OpenChange/MAPIStoreTable.m +++ b/OpenChange/MAPIStoreTable.m @@ -339,6 +339,10 @@ static Class NSDataK, NSStringK; cachedRestrictedKeys = nil; [cachedKeys release]; cachedKeys = nil; + [lastChildKey release]; + lastChildKey = nil; + [lastChild release]; + lastChild = nil; } - (id) lookupChild: (NSString *) childKey From 32b6ee0c2b6b73a3332ef9fd087d6c827caf2d21 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 12 Jan 2011 00:07:55 +0000 Subject: [PATCH 12/14] Monotone-Parent: 454eba06ab9f1fc198036d0eab58db1a689f60ed Monotone-Revision: 69395b75fdbee1ede0021d893697e1ed210ba3a7 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-01-12T00:07:55 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 4 ++++ OpenChange/MAPIStoreMessageTable.m | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index cc13abb17..b755053c0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,10 @@ 2011-01-11 Wolfgang Sourdeau + * OpenChange/MAPIStoreMessageTable.m + (-getChildProperty:forKey:withTag:): fixed PR_ACCESS and + PR_ACCESS_LEVEL to avoid displaying the "read-only" status. + * OpenChange/MAPIStoreTable.m (-cleanupCaches): remove lastChild from cache too. diff --git a/OpenChange/MAPIStoreMessageTable.m b/OpenChange/MAPIStoreMessageTable.m index 069328da7..c0beca286 100644 --- a/OpenChange/MAPIStoreMessageTable.m +++ b/OpenChange/MAPIStoreMessageTable.m @@ -87,10 +87,10 @@ static MAPIStoreMapping *mapping; *data = MAPILongLongValue (memCtx, 0); break; case PR_ACCESS: // TODO - *data = MAPILongValue (memCtx, 0x02); + *data = MAPILongValue (memCtx, 0x03); break; case PR_ACCESS_LEVEL: // TODO - *data = MAPILongValue (memCtx, 0x00000000); + *data = MAPILongValue (memCtx, 0x01); break; case PR_VIEW_STYLE: case PR_VIEW_MAJORVERSION: From ab1580efe5ad2cd41fea548e2af3a5c03387b948 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 12 Jan 2011 00:10:21 +0000 Subject: [PATCH 13/14] Monotone-Parent: 69395b75fdbee1ede0021d893697e1ed210ba3a7 Monotone-Revision: 360a0a073b90f6a8e37d542c557726bd5c885e3d Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-01-12T00:10:21 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 7 +++ OpenChange/MAPIStoreContext.m | 105 +++++++++++++++++++++------------- 2 files changed, 72 insertions(+), 40 deletions(-) diff --git a/ChangeLog b/ChangeLog index b755053c0..1b506f3e7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,13 @@ 2011-01-11 Wolfgang Sourdeau + * OpenChange/MAPIStoreContext.m + (-createMessagePropertiesWithMID:inFID:isAssociated:): added a + retain count handling. + (-releaseRecordWithFMID:ofTableType:): same as above. + (-_saveOrSubmitChangesInMessageWithMID:andFlags:save:): cleanup + table caches even for modifications. + * OpenChange/MAPIStoreMessageTable.m (-getChildProperty:forKey:withTag:): fixed PR_ACCESS and PR_ACCESS_LEVEL to avoid displaying the "read-only" status. diff --git a/OpenChange/MAPIStoreContext.m b/OpenChange/MAPIStoreContext.m index 29ff9e372..e4dd38f7c 100644 --- a/OpenChange/MAPIStoreContext.m +++ b/OpenChange/MAPIStoreContext.m @@ -823,8 +823,8 @@ _prepareContextClass (struct mapistore_context *newMemCtx, { NSString *childURL, *childKey, *folderURL; MAPIStoreTable *table; - int rc; BOOL isAssociated; + int rc; childURL = [mapping urlFromID: mid]; if (childURL) @@ -862,20 +862,39 @@ _prepareContextClass (struct mapistore_context *newMemCtx, inFID: (uint64_t) fid isAssociated: (BOOL) isAssociated { - NSMutableDictionary *newMessage; + NSMutableDictionary *messageProperties; NSNumber *midNbr; + NSUInteger retainCount; - [self logWithFormat: @"METHOD '%s' -- mid: 0x%.16x, fid: 0x%.16x", - __FUNCTION__, mid, fid]; - newMessage = [NSMutableDictionary new]; - [newMessage setObject: [NSNumber numberWithUnsignedLongLong: fid] - forKey: @"fid"]; - midNbr = [NSNumber numberWithUnsignedLongLong: mid]; - [newMessage setObject: midNbr forKey: @"mid"]; - [newMessage setObject: [NSNumber numberWithBool: isAssociated] - forKey: @"associated"]; - [messages setObject: newMessage forKey: midNbr]; - [newMessage release]; + messageProperties = [messages objectForKey: + [NSNumber numberWithUnsignedLongLong: mid]]; + if (messageProperties) + { + [self logWithFormat: + @"METHOD '%s' -- mid: 0x%.16x, fid: 0x%.16x; retainCount++", + __FUNCTION__, mid, fid]; + retainCount = [[messageProperties objectForKey: @"mapiRetainCount"] + unsignedIntValue]; + [messageProperties + setObject: [NSNumber numberWithUnsignedInt: retainCount + 1] + forKey: @"mapiRetainCount"]; + } + else + { + [self logWithFormat: @"METHOD '%s' -- mid: 0x%.16x, fid: 0x%.16x", + __FUNCTION__, mid, fid]; + messageProperties = [NSMutableDictionary new]; + [messageProperties setObject: [NSNumber numberWithUnsignedLongLong: fid] + forKey: @"fid"]; + midNbr = [NSNumber numberWithUnsignedLongLong: mid]; + [messageProperties setObject: midNbr forKey: @"mid"]; + [messageProperties setObject: [NSNumber numberWithBool: isAssociated] + forKey: @"associated"]; + [messageProperties setObject: [NSNumber numberWithInt: 1] + forKey: @"mapiRetainCount"]; + [messages setObject: messageProperties forKey: midNbr]; + [messageProperties release]; + } return MAPISTORE_SUCCESS; } @@ -940,42 +959,36 @@ _prepareContextClass (struct mapistore_context *newMemCtx, NSMutableDictionary *messageProperties; NSString *messageURL; uint64_t fid; - BOOL viewMessage; + BOOL associated; - viewMessage = NO; messageProperties = [messages objectForKey: [NSNumber numberWithUnsignedLongLong: mid]]; if (messageProperties) { messageURL = [mapping urlFromID: mid]; - if ([[messageProperties objectForKey: @"associated"] boolValue]) + associated = [[messageProperties objectForKey: @"associated"] boolValue]; + if (messageURL) { - if (messageURL) + if (associated) message = [self lookupFAIObject: messageURL]; else - { - fid = [[messageProperties objectForKey: @"fid"] - unsignedLongLongValue]; - message = [self _createMessageOfClass: [messageProperties objectForKey: MAPIPropertyKey (PR_MESSAGE_CLASS_UNICODE)] - associated: YES - withMID: mid inFID: fid]; - } + message = [self lookupObject: messageURL]; } else { - if (messageURL) - message = [self lookupObject: messageURL]; - else - { - fid = [[messageProperties objectForKey: @"fid"] - unsignedLongLongValue]; - message = [self _createMessageOfClass: [messageProperties objectForKey: MAPIPropertyKey (PR_MESSAGE_CLASS_UNICODE)] - associated: NO - withMID: mid inFID: fid]; - } + fid = [[messageProperties objectForKey: @"fid"] + unsignedLongLongValue]; + message = [self _createMessageOfClass: [messageProperties objectForKey: MAPIPropertyKey (PR_MESSAGE_CLASS_UNICODE)] + associated: associated + withMID: mid inFID: fid]; } if (message) { + if (associated) + [faiTable cleanupCaches]; + else + [messageTable cleanupCaches]; + [message setMAPIProperties: messageProperties]; if (isSave) [message MAPISave]; @@ -1416,20 +1429,32 @@ _prepareContextClass (struct mapistore_context *newMemCtx, - (int) releaseRecordWithFMID: (uint64_t) fmid ofTableType: (uint8_t) tableType { - int rc; NSNumber *midNbr; + NSMutableDictionary *messageProperties; + NSUInteger retainCount; + int rc; switch (tableType) { case MAPISTORE_MESSAGE_TABLE: rc = MAPISTORE_SUCCESS; midNbr = [NSNumber numberWithUnsignedLongLong: fmid]; - if ([messages objectForKey: midNbr]) + messageProperties = [messages objectForKey: midNbr]; + if (messageProperties) { - [self logWithFormat: @"message with mid %.16x successfully removed" - @" from message cache", - fmid]; - [messages removeObjectForKey: midNbr]; + retainCount = [[messageProperties objectForKey: @"mapiRetainCount"] + unsignedIntValue]; + if (retainCount == 1) + { + [self logWithFormat: @"message with mid %.16x successfully removed" + @" from message cache", + fmid]; + [messages removeObjectForKey: midNbr]; + } + else + [messageProperties + setObject: [NSNumber numberWithUnsignedInt: retainCount - 1] + forKey: @"mapiRetainCount"]; } else [self warnWithFormat: @"message with mid %.16x not found" From 7ec5d9748a4cf78ce727625557f022c5c877f32b Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 12 Jan 2011 00:23:10 +0000 Subject: [PATCH 14/14] Monotone-Parent: 360a0a073b90f6a8e37d542c557726bd5c885e3d Monotone-Revision: c284de68225198e750f24bf15d220c2e6a7c20e2 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-01-12T00:23:10 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 7 +++++++ OpenChange/SOGoAppointmentObject+MAPIStore.m | 5 +++++ OpenChange/SOGoTaskObject+MAPIStore.m | 6 +++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 1b506f3e7..935d2b160 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,13 @@ 2011-01-11 Wolfgang Sourdeau + * OpenChange/SOGoTaskObject+MAPIStore.m (-setMAPIProperties): + release fullCalendar and safeCalendar to force a rebuild of + the root object when next requested. + + * OpenChange/SOGoAppointmentObject+MAPIStore.m (-setMAPIProperties): + idem. + * OpenChange/MAPIStoreContext.m (-createMessagePropertiesWithMID:inFID:isAssociated:): added a retain count handling. diff --git a/OpenChange/SOGoAppointmentObject+MAPIStore.m b/OpenChange/SOGoAppointmentObject+MAPIStore.m index 21bfdf9c7..e11e1745c 100644 --- a/OpenChange/SOGoAppointmentObject+MAPIStore.m +++ b/OpenChange/SOGoAppointmentObject+MAPIStore.m @@ -109,6 +109,11 @@ // MAPIStoreDumpMessageProperties (properties); ASSIGN (content, [vCalendar versitString]); + + [fullCalendar release]; + fullCalendar = nil; + [safeCalendar release]; + safeCalendar = nil; } @end diff --git a/OpenChange/SOGoTaskObject+MAPIStore.m b/OpenChange/SOGoTaskObject+MAPIStore.m index d8f00dbec..4a37b4b75 100644 --- a/OpenChange/SOGoTaskObject+MAPIStore.m +++ b/OpenChange/SOGoTaskObject+MAPIStore.m @@ -164,8 +164,12 @@ // } // MAPIStoreDumpMessageProperties (properties); - ASSIGN (content, [vCalendar versitString]); + + [fullCalendar release]; + fullCalendar = nil; + [safeCalendar release]; + safeCalendar = nil; } @end