[evolution-kolab/ek-wip-porting] kolab-util-contact: added function to get EContact supported fields



commit df3c3f42543b480bf31313acfe3bdb6a46db0215
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Mon Mar 19 20:07:21 2012 +0100

    kolab-util-contact: added function to get EContact supported fields
    
    * returns the names of EContact fields
    * taken from evolution-mapi, thanks guys

 src/addressbook/kolab-util-contact.c |   74 ++++++++++++++++++++++++++++++++++
 src/addressbook/kolab-util-contact.h |    3 +
 2 files changed, 77 insertions(+), 0 deletions(-)
---
diff --git a/src/addressbook/kolab-util-contact.c b/src/addressbook/kolab-util-contact.c
index d86884c..cac4536 100644
--- a/src/addressbook/kolab-util-contact.c
+++ b/src/addressbook/kolab-util-contact.c
@@ -34,6 +34,65 @@
 
 /*----------------------------------------------------------------------------*/
 
+/* taken from mapi, for now we just need the EContact field IDs
+ * to report the fields supported by evolution-kolab
+ * (is there not an EContact convenience function for that ?!?)
+ */
+
+static const struct field_element_mapping {
+	EContactField field_id;
+#if 0
+	uint32_t mapi_id;
+	gint element_type;
+#endif
+} mappings [] = {
+	{ E_CONTACT_UID,		/* PidTagMid,			ELEMENT_TYPE_SKIP_SET */ },
+	{ E_CONTACT_REV,		/* PidTagLastModificationTime,	ELEMENT_TYPE_SIMPLE */ },
+
+	{ E_CONTACT_FILE_AS,		/* PidLidFileUnder,		ELEMENT_TYPE_SIMPLE */ },
+	{ E_CONTACT_FULL_NAME,		/* PidTagDisplayName,		ELEMENT_TYPE_SIMPLE */ },
+	{ E_CONTACT_GIVEN_NAME,		/* PidTagGivenName,		ELEMENT_TYPE_SIMPLE */ },
+	{ E_CONTACT_FAMILY_NAME,	/* PidTagSurname,		ELEMENT_TYPE_SIMPLE */ },
+	{ E_CONTACT_NICKNAME,		/* PidTagNickname,		ELEMENT_TYPE_SIMPLE */ },
+
+	{ E_CONTACT_EMAIL_1,		/* PidLidEmail1OriginalDisplayName,ELEMENT_TYPE_SIMPLE */ },
+	{ E_CONTACT_EMAIL_2,		/* PidLidEmail2EmailAddress,	ELEMENT_TYPE_SIMPLE */ },
+	{ E_CONTACT_EMAIL_3,		/* PidLidEmail3EmailAddress,	ELEMENT_TYPE_SIMPLE */ },
+	{ E_CONTACT_IM_AIM,		/* PidLidInstantMessagingAddress,	ELEMENT_TYPE_COMPLEX */ },
+
+	{ E_CONTACT_PHONE_BUSINESS,	/* PidTagBusinessTelephoneNumber,	ELEMENT_TYPE_SIMPLE */},
+	{ E_CONTACT_PHONE_HOME,		/* PidTagHomeTelephoneNumber,	ELEMENT_TYPE_SIMPLE */ },
+	{ E_CONTACT_PHONE_MOBILE,	/* PidTagMobileTelephoneNumber,	ELEMENT_TYPE_SIMPLE */ },
+	{ E_CONTACT_PHONE_HOME_FAX,	/* PidTagHomeFaxNumber,		ELEMENT_TYPE_SIMPLE */ },
+	{ E_CONTACT_PHONE_BUSINESS_FAX,	/* PidTagBusinessFaxNumber,	ELEMENT_TYPE_SIMPLE */ },
+	{ E_CONTACT_PHONE_PAGER,	/* PidTagPagerTelephoneNumber,	ELEMENT_TYPE_SIMPLE */ },
+	{ E_CONTACT_PHONE_ASSISTANT,	/* PidTagAssistantTelephoneNumber,ELEMENT_TYPE_SIMPLE */ },
+	{ E_CONTACT_PHONE_COMPANY,	/* PidTagCompanyMainTelephoneNumber,ELEMENT_TYPE_SIMPLE */ },
+
+	{ E_CONTACT_HOMEPAGE_URL,	/* PidLidHtml,			ELEMENT_TYPE_SIMPLE */ },
+	{ E_CONTACT_FREEBUSY_URL,	/* PidLidFreeBusyLocation,	ELEMENT_TYPE_SIMPLE */ },
+
+	{ E_CONTACT_ROLE,		/* PidTagProfession,		ELEMENT_TYPE_SIMPLE */ },
+	{ E_CONTACT_TITLE,		/* PidTagTitle,			ELEMENT_TYPE_SIMPLE */ },
+	{ E_CONTACT_ORG,		/* PidTagCompanyName,		ELEMENT_TYPE_SIMPLE */ },
+	{ E_CONTACT_ORG_UNIT,		/* PidTagDepartmentName,	ELEMENT_TYPE_SIMPLE */ },
+	{ E_CONTACT_MANAGER,		/* PidTagManagerName,		ELEMENT_TYPE_SIMPLE */ },
+	{ E_CONTACT_ASSISTANT,		/* PidTagAssistant,		ELEMENT_TYPE_SIMPLE */ },
+
+	{ E_CONTACT_OFFICE,		/* PidTagOfficeLocation,	ELEMENT_TYPE_SIMPLE */ },
+	{ E_CONTACT_SPOUSE,		/* PidTagSpouseName,		ELEMENT_TYPE_SIMPLE */ },
+
+	{ E_CONTACT_BIRTH_DATE,		/* PidTagBirthday,		ELEMENT_TYPE_COMPLEX */ },
+	{ E_CONTACT_ANNIVERSARY,	/* PidTagWeddingAnniversary,	ELEMENT_TYPE_COMPLEX */ },
+
+	{ E_CONTACT_NOTE,		/* PidTagBody,			ELEMENT_TYPE_SIMPLE */ },
+
+	{ E_CONTACT_ADDRESS_HOME,	/* PidLidHomeAddress,		ELEMENT_TYPE_COMPLEX */ },
+	{ E_CONTACT_ADDRESS_WORK,	/* PidLidOtherAddress,		ELEMENT_TYPE_COMPLEX */ }
+};
+
+/*----------------------------------------------------------------------------*/
+
 gboolean
 kolab_util_contact_has_id (EContact *contact)
 {
@@ -194,5 +253,20 @@ kolab_util_contact_err_to_edb_err (GError **e_err,
 	g_propagate_error (e_err, tmp_err);
 }
 
+/* return with g_slist_free(), 'data' pointers (strings) are not newly allocated */
+GSList *
+kolab_utils_contact_get_supported_fields (void)
+{
+	guint ii = 0;
+	GSList *fields = NULL;
+
+	for (ii = 0; ii < G_N_ELEMENTS (mappings); ii++) {
+		fields = g_slist_append (fields, (gpointer) e_contact_field_name (mappings[ii].field_id));
+	}
+
+	fields = g_slist_append (fields, (gpointer) e_contact_field_name (E_CONTACT_BOOK_URI));
+
+	return fields;
+}
 
 /*----------------------------------------------------------------------------*/
diff --git a/src/addressbook/kolab-util-contact.h b/src/addressbook/kolab-util-contact.h
index 1e37ced..154e6bb 100644
--- a/src/addressbook/kolab-util-contact.h
+++ b/src/addressbook/kolab-util-contact.h
@@ -69,6 +69,9 @@ kolab_util_contact_err_to_edb_err (GError **e_err,
                                    const gchar *func,
                                    guint line);
 
+GSList*
+kolab_utils_contact_get_supported_fields (void);
+
 G_END_DECLS
 
 /*----------------------------------------------------------------------------*/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]