diff --git a/mozilla/mailnews/addrbook/public/nsIAddrDatabase.idl b/mozilla/mailnews/addrbook/public/nsIAddrDatabase.idl index 74dede01020..952654715c1 100644 --- a/mozilla/mailnews/addrbook/public/nsIAddrDatabase.idl +++ b/mozilla/mailnews/addrbook/public/nsIAddrDatabase.idl @@ -50,6 +50,12 @@ [ptr] native nsIMdbRow(nsIMdbRow); %{C++ +// this is the prefix we for attributes that are specific +// to the mozilla addressbook, and weren't in 4.x and aren't specified in +// RFC 2789. used when exporting and import LDIF +// see nsTextAddress.cpp, nsAddressBook.cpp +#define MOZ_AB_LDIF_PREFIX "mozilla" + // note, GeneratedName is not a real column // if you change any of this, make sure to change // Get / Set CardValue in nsAbCardProperty.cpp diff --git a/mozilla/mailnews/addrbook/src/nsAddressBook.cpp b/mozilla/mailnews/addrbook/src/nsAddressBook.cpp index 1d1bc25d984..7d03d77fe75 100644 --- a/mozilla/mailnews/addrbook/src/nsAddressBook.cpp +++ b/mozilla/mailnews/addrbook/src/nsAddressBook.cpp @@ -91,6 +91,11 @@ #define LDIF_LINEBREAK_LEN 2 #endif +// our schema is not fixed yet, but we still want some sort of objectclass +// for now, use obsolete in the class name, hinting that this will change +// see bugs bug #116692 and #118454 +#define MOZ_AB_OBJECTCLASS "mozillaAbPersonObsolete" + // for now, these should be in the same order as they are in the import code // see importMsgProperties and nsImportStringBundle.h @@ -109,21 +114,17 @@ struct ExportAttributesTableStruct // // here's how we're coming up with the ldapPropertyName values // if they are specified in RFC 2798, use them -// else use the 4.x LDIF attribute names -// -// the import code has to support 4.x LDIF, and the more attributes we support -// the less lossy we are when going from AB -> LDIF -> AB -// -// one day, the nsnull values will be replaced by attribute names -// and we'll fix the import code to handle them. -// until then, AB -> LDIF -> AB will be lossy. see bug #119360 +// else use the 4.x LDIF attribute names (for example, "xmozillanickname" +// as we want to allow export from mozilla back to 4.x, and other apps +// are probably out there that can handle 4.x LDIF) +// else use the MOZ_AB_LDIF_PREFIX prefix, see nsIAddrDatabase.idl static ExportAttributesTableStruct EXPORT_ATTRIBUTES_TABLE[] = { {kFirstNameColumn, "givenName", PR_TRUE}, {kLastNameColumn, "sn", PR_TRUE}, {kDisplayNameColumn, "cn", PR_TRUE}, {kNicknameColumn, "xmozillanickname", PR_TRUE}, {kPriEmailColumn, "mail", PR_TRUE}, - {k2ndEmailColumn, nsnull, PR_TRUE}, + {k2ndEmailColumn, MOZ_AB_LDIF_PREFIX "SecondEmail", PR_TRUE}, {kPreferMailFormatColumn, "xmozillausehtmlmail", PR_FALSE}, {kLastModifiedDateColumn, "modifytimestamp", PR_FALSE}, {kWorkPhoneColumn, "telephoneNumber", PR_TRUE}, @@ -132,13 +133,13 @@ static ExportAttributesTableStruct EXPORT_ATTRIBUTES_TABLE[] = { {kPagerColumn, "pager", PR_TRUE}, {kCellularColumn, "mobile", PR_TRUE}, {kHomeAddressColumn, "homePostalAddress", PR_TRUE}, - {kHomeAddress2Column, nsnull, PR_TRUE}, - {kHomeCityColumn, nsnull, PR_TRUE}, - {kHomeStateColumn, nsnull, PR_TRUE}, - {kHomeZipCodeColumn, nsnull, PR_TRUE}, - {kHomeCountryColumn, nsnull, PR_TRUE}, + {kHomeAddress2Column, MOZ_AB_LDIF_PREFIX "HomePostalAddress2", PR_TRUE}, + {kHomeCityColumn, MOZ_AB_LDIF_PREFIX "HomeLocalityName", PR_TRUE}, + {kHomeStateColumn, MOZ_AB_LDIF_PREFIX "HomeStreet", PR_TRUE}, + {kHomeZipCodeColumn, MOZ_AB_LDIF_PREFIX "HomePostalCode", PR_TRUE}, + {kHomeCountryColumn, MOZ_AB_LDIF_PREFIX "HomeCountryName", PR_TRUE}, {kWorkAddressColumn, "postalAddress", PR_TRUE}, - {kWorkAddress2Column, nsnull, PR_TRUE}, + {kWorkAddress2Column, MOZ_AB_LDIF_PREFIX "PostalAddress2", PR_TRUE}, {kWorkCityColumn, "l", PR_TRUE}, {kWorkStateColumn, "st", PR_TRUE}, {kWorkZipCodeColumn, "postalCode", PR_TRUE}, @@ -148,9 +149,9 @@ static ExportAttributesTableStruct EXPORT_ATTRIBUTES_TABLE[] = { {kCompanyColumn, "o", PR_TRUE}, {kWebPage1Column, "workurl", PR_TRUE}, {kWebPage2Column, "homeurl", PR_TRUE}, - {kBirthYearColumn, nsnull, PR_TRUE}, - {kBirthMonthColumn, nsnull, PR_TRUE}, - {kBirthDayColumn, nsnull, PR_TRUE}, + {kBirthYearColumn, nsnull, PR_TRUE}, // unused for now + {kBirthMonthColumn, nsnull, PR_TRUE}, // unused for now + {kBirthDayColumn, nsnull, PR_TRUE}, // unused for now {kCustom1Column, "custom1", PR_TRUE}, {kCustom2Column, "custom2", PR_TRUE}, {kCustom3Column, "custom3", PR_TRUE}, @@ -1725,8 +1726,10 @@ nsresult nsAddressBook::AppendBasicLDIFForCard(nsIAbCard *aCard, nsAFlatCString aResult += LDIF_LINEBREAK \ "objectclass: top" LDIF_LINEBREAK \ "objectclass: person" LDIF_LINEBREAK \ - "objectclass: organizationalPerson" LDIF_LINEBREAK - "objectclass: inetOrgPerson" LDIF_LINEBREAK; + "objectclass: organizationalPerson" LDIF_LINEBREAK \ + "objectclass: inetOrgPerson" LDIF_LINEBREAK \ + "objectclass: " MOZ_AB_OBJECTCLASS LDIF_LINEBREAK; + return rv; } diff --git a/mozilla/mailnews/import/text/src/nsTextAddress.cpp b/mozilla/mailnews/import/text/src/nsTextAddress.cpp index 266cc120c68..fd784c33a36 100644 --- a/mozilla/mailnews/import/text/src/nsTextAddress.cpp +++ b/mozilla/mailnews/import/text/src/nsTextAddress.cpp @@ -1017,7 +1017,8 @@ void nsTextAddress::AddLdifColToDatabase(nsIMdbRow* newRow, char* typeSlot, char nsCAutoString colType(typeSlot); nsCAutoString column(valueSlot); - // 4.x exports attributes like "givenname", mozilla does "givenName" to be compliant with RFC 2798 + // 4.x exports attributes like "givenname", + // mozilla does "givenName" to be compliant with RFC 2798 ToLowerCase(colType); mdb_u1 firstByte = (mdb_u1)(colType.get())[0]; @@ -1123,10 +1124,23 @@ void nsTextAddress::AddLdifColToDatabase(nsIMdbRow* newRow, char* typeSlot, char if (colType.Equals("mail") ) m_database->AddPrimaryEmail(newRow, column.get()); else if ( colType.Equals("mobile") ) - m_database->AddCellularNumber(newRow, column.get()); + m_database->AddCellularNumber(newRow, column.get()); else if (colType.Equals("member") && bIsList ) m_database->AddLdifListMember(newRow, column.get()); - + else if (colType.Equals(MOZ_AB_LDIF_PREFIX "secondemail")) + m_database->Add2ndEmail(newRow, column.get()); + else if (colType.Equals(MOZ_AB_LDIF_PREFIX "postaladdress2")) + m_database->AddWorkAddress2(newRow, column.get()); + else if (colType.Equals(MOZ_AB_LDIF_PREFIX "homepostaladdress2")) + m_database->AddHomeAddress2(newRow, column.get()); + else if (colType.Equals(MOZ_AB_LDIF_PREFIX "homelocalityname")) + m_database->AddHomeCity(newRow, column.get()); + else if (colType.Equals(MOZ_AB_LDIF_PREFIX "homestreet")) + m_database->AddHomeState(newRow, column.get()); + else if (colType.Equals(MOZ_AB_LDIF_PREFIX "homepostalcode")) + m_database->AddHomeZipCode(newRow, column.get()); + else if (colType.Equals(MOZ_AB_LDIF_PREFIX "homecountryname")) + m_database->AddHomeCountry(newRow, column.get()); break; // 'm' case 'n':