From 4c3c741d9f6b05eb67c0bb1c454b5f9027682493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Vall=C3=A9s?= Date: Mon, 23 Feb 2015 14:45:16 +0100 Subject: [PATCH] oc-contacts: Save missing contact properties in database --- OpenChange/MAPIStoreContactsMessage.m | 142 +++++++++++++++++++++++++- 1 file changed, 140 insertions(+), 2 deletions(-) diff --git a/OpenChange/MAPIStoreContactsMessage.m b/OpenChange/MAPIStoreContactsMessage.m index c866670f2..cccb495e1 100644 --- a/OpenChange/MAPIStoreContactsMessage.m +++ b/OpenChange/MAPIStoreContactsMessage.m @@ -170,6 +170,21 @@ return MAPISTORE_SUCCESS; } +- (int) getPidTagProfession: (void **) data + inMemCtx: (TALLOC_CTX *) memCtx +{ + NSString *stringValue; + int rc = MAPISTORE_SUCCESS; + + stringValue = [[sogoObject vCard] role]; + if (stringValue) + *data = [stringValue asUnicodeInMemCtx: memCtx]; + else + rc = MAPISTORE_ERR_NOT_FOUND; + + return rc; +} + - (int) getPidTagCompanyName: (void **) data inMemCtx: (TALLOC_CTX *) memCtx { @@ -744,6 +759,86 @@ return rc; } +- (int) getPidTagSpouseName: (void **) data + inMemCtx: (TALLOC_CTX *) memCtx +{ + NSString *stringValue; + int rc = MAPISTORE_SUCCESS; + + stringValue = [[[sogoObject vCard] uniqueChildWithTag: @"x-ms-spouse"] + flattenedValuesForKey: @""]; + if (stringValue) + *data = [stringValue asUnicodeInMemCtx: memCtx]; + else + rc = MAPISTORE_ERR_NOT_FOUND; + + return rc; +} + +- (int) getPidTagManagerName: (void **) data + inMemCtx: (TALLOC_CTX *) memCtx +{ + NSString *stringValue; + int rc = MAPISTORE_SUCCESS; + + stringValue = [[[sogoObject vCard] uniqueChildWithTag: @"x-ms-manager"] + flattenedValuesForKey: @""]; + if (stringValue) + *data = [stringValue asUnicodeInMemCtx: memCtx]; + else + rc = MAPISTORE_ERR_NOT_FOUND; + + return rc; +} + +- (int) getPidTagAssistant: (void **) data + inMemCtx: (TALLOC_CTX *) memCtx +{ + NSString *stringValue; + int rc = MAPISTORE_SUCCESS; + + stringValue = [[[sogoObject vCard] uniqueChildWithTag: @"x-ms-assistant"] + flattenedValuesForKey: @""]; + if (stringValue) + *data = [stringValue asUnicodeInMemCtx: memCtx]; + else + rc = MAPISTORE_ERR_NOT_FOUND; + + return rc; +} + +- (int) getPidTagOfficeLocation: (void **) data + inMemCtx: (TALLOC_CTX *) memCtx +{ + NSString *stringValue; + int rc = MAPISTORE_SUCCESS; + + stringValue = [[[sogoObject vCard] uniqueChildWithTag: @"x-ms-office"] + flattenedValuesForKey: @""]; + if (stringValue) + *data = [stringValue asUnicodeInMemCtx: memCtx]; + else + rc = MAPISTORE_ERR_NOT_FOUND; + + return rc; +} + +- (int) getPidLidFreeBusyLocation: (void **) data + inMemCtx: (TALLOC_CTX *) memCtx +{ + NSString *stringValue; + int rc = MAPISTORE_SUCCESS; + + stringValue = [[[sogoObject vCard] uniqueChildWithTag: @"fburl"] + flattenedValuesForKey: @""]; + if (stringValue) + *data = [stringValue asUnicodeInMemCtx: memCtx]; + else + rc = MAPISTORE_ERR_NOT_FOUND; + + return rc; +} + // // Decomposed fullname getters // @@ -1154,12 +1249,18 @@ fromProperties: (NSDictionary *) attachmentProps // - // job title, nickname, company name, deparment, work url, im address/screen name and birthday + // job title, profession, nickname, company name, deparment, work url, im address/screen name and birthday // value = [properties objectForKey: MAPIPropertyKey(PR_TITLE_UNICODE)]; if (value) [newCard setTitle: value]; + value = [properties objectForKey: MAPIPropertyKey(PR_PROFESSION_UNICODE)]; + if (value) + { + [newCard setRole: value]; + } + value = [properties objectForKey: MAPIPropertyKey(PR_NICKNAME_UNICODE)]; if (value) [newCard setNickname: value]; @@ -1194,7 +1295,9 @@ fromProperties: (NSDictionary *) attachmentProps [newCard setBday: [value descriptionWithCalendarFormat: @"%Y-%m-%d"]]; } - /* wedding anniversary */ + // + // wedding anniversary, spouse's name, manager's name, assistant's name, office location, freebusy location + // value = [properties objectForKey: MAPIPropertyKey(PidTagWeddingAnniversary)]; if (value) { @@ -1203,6 +1306,41 @@ fromProperties: (NSDictionary *) attachmentProps forKey: @""]; } + value = [properties objectForKey: MAPIPropertyKey(PR_SPOUSE_NAME_UNICODE)]; + if (value) + { + [[newCard uniqueChildWithTag: @"x-ms-spouse"] + setSingleValue: value forKey: @""]; + } + + value = [properties objectForKey: MAPIPropertyKey(PR_MANAGER_NAME_UNICODE)]; + if (value) + { + [[newCard uniqueChildWithTag: @"x-ms-manager"] + setSingleValue: value forKey: @""]; + } + + value = [properties objectForKey: MAPIPropertyKey(PR_ASSISTANT_UNICODE)]; + if (value) + { + [[newCard uniqueChildWithTag: @"x-ms-assistant"] + setSingleValue: value forKey: @""]; + } + + value = [properties objectForKey: MAPIPropertyKey(PR_OFFICE_LOCATION_UNICODE)]; + if (value) + { + [[newCard uniqueChildWithTag: @"x-ms-office"] + setSingleValue: value forKey: @""]; + } + + value = [properties objectForKey: MAPIPropertyKey(PidLidFreeBusyLocation)]; + if (value) + { + [[newCard uniqueChildWithTag: @"fburl"] + setSingleValue: value forKey: @""]; + } + /* photo */ if ([attachmentParts count] > 0) {