-static int ldif_conv_table[LDIF_ITEM_FIELDS] = {
- NAME, /* "cn" */
- EMAIL, /* "mail" */
- ADDRESS, /* "streetaddress" */
- ADDRESS2, /* "streetaddress2" */
- CITY, /* "locality" */
- STATE, /* "st" */
- ZIP, /* "postalcode" */
- COUNTRY, /* "countryname" */
- PHONE, /* "homephone" */
- NOTES, /* "description" */
- URL, /* "homeurl" */
- FAX, /* "facsimiletelephonenumber" */
- MOBILEPHONE, /* "cellphone" */
- WORKPHONE, /* "xmozillaanyphone" */
- NICK, /* "xmozillanickname" */
- -1, /* "objectclass" */ /* this must be the last entry */
+/* Used to map LDIF attr names from input to
+ the abook restricted set of standard fields. */
+typedef struct {
+ char *key;
+ int index;
+} ldif_available_items;
+
+static ldif_available_items ldif_conv_table[] = {
+ /* initial field names respect the field_types enum
+ from database.h but this is only for readability.
+ This ldif_item struct allow use to define multiple
+ LDIF field names ("attribute names") for one abook field */
+
+ {"cn", NAME}, // 0
+ {"mail", EMAIL},
+ {"streetaddress", ADDRESS},
+ {"streetaddress2", ADDRESS2},
+ {"locality", CITY},
+ {"st", STATE},
+ {"postalcode", ZIP},
+ {"countryname", COUNTRY},
+ {"homephone", PHONE},
+ {"telephonenumber", WORKPHONE}, // workphone, according to Mozilla
+ {"facsimiletelephonenumber", FAX},
+ {"cellphone", MOBILEPHONE},
+ {"mozillanickname", NICK},
+ {"homeurl", URL},
+ {"description", NOTES},
+ {"anniversary", ANNIVERSARY},
+ {"ou", GROUPS}, // 16
+
+ // here comes a couple of aliases
+ {"mozillasecondemail", EMAIL},
+ {"homecity", CITY},
+ {"zip", ZIP},
+ {"tel", PHONE},
+ {"xmozillaanyphone", WORKPHONE}, // ever used ?
+ {"workphone", WORKPHONE},
+ {"fax", FAX},
+ {"telexnumber", FAX},
+ {"mobilephone", MOBILEPHONE},
+ {"mobile", MOBILEPHONE},
+ {"xmozillanickname", NICK},
+ {"labeledURI", URL},
+ {"notes", NOTES},
+ {"birthday", ANNIVERSARY},
+ {"category", GROUPS},
+
+ /* TODO:
+ "sn": append to lastname ?
+ "surname": append to lastname ?
+ "givenname": prepend to firstname ? */
+
+ /* here starts dummy fields:
+
+ As long as additional indexes are created
+ (using the above ldif_field_types),
+ any other LDIF attr name can be added and
+ used during ldif entry processing.
+ But obviously fields > ITEM_FIELDS (database.h) won't be
+ copied into the final *list_item. */
+
+ /* - to avoid mistake, don't use the special ITEM_FIELDS value.
+ - see also: http://mxr.mozilla.org/comm-central/source/mailnews/addrbook/src/nsAbLDIFService.cpp */
+
+ // used to check valid LDIF records:
+ {"objectclass", LDIF_OBJECTCLASS}