|
|
@ -10,6 +10,26 @@ const TbContacts = { |
|
|
|
const result = { book: null, card: null }; |
|
|
|
while (!result.card && books.hasMoreElements()) { |
|
|
|
const ab = books.getNext().QueryInterface(Ci.nsIAbDirectory); |
|
|
|
// Thunderbird supports four different types of address book:
|
|
|
|
// 1) Its own local address book.
|
|
|
|
// 2) LDAP address book.
|
|
|
|
// 3) On Windows: The Outlook address book via these prefs:
|
|
|
|
// ldap_2.servers.Outlook.description: "Outlook"
|
|
|
|
// ldap_2.servers.Outlook.dirType: 3
|
|
|
|
// ldap_2.servers.Outlook.uri: "moz-aboutlookdirectory://op/"
|
|
|
|
// 4) On Mac: The Mac address book which can also access other external address books,
|
|
|
|
// for example via Exchange, iCloud, Google and a few more.
|
|
|
|
// These have the following peculiarities:
|
|
|
|
// For LDAP and Outlook ABs, the `cardForEmailAddress()` method is not implemented,
|
|
|
|
// one would have to do a `nsIAbDirectoryQuery.doQuery()` to locate a card.
|
|
|
|
// The Mac AB doesn't return a stable UID, that is, in the next Thunderbird session
|
|
|
|
// a new UID is returned.
|
|
|
|
// Mac and LDAP ABs are readlonly, the Outlook AB is not.
|
|
|
|
// Right now, we're only looking at local ABs.
|
|
|
|
let abURI = ab.URI; |
|
|
|
if (abURI.startsWith("moz-abldapdirectory:") || abURI.startsWith("moz-abosxdirectory:") || |
|
|
|
abURI.startsWith("moz-aboutlookdirectory:")) continue; |
|
|
|
|
|
|
|
try { |
|
|
|
const card = ab.cardForEmailAddress(emailAddress); |
|
|
|
if (card) { |
|
|
@ -17,9 +37,7 @@ const TbContacts = { |
|
|
|
result.card = card; |
|
|
|
} |
|
|
|
} catch (ex) { |
|
|
|
console.error( |
|
|
|
`Error (${ex.message}) fetching card from address book ${ab.dirName} (remote: ${ab.isRemote}) for ${emailAddress}`, |
|
|
|
); |
|
|
|
console.error(`Error (${ex.message}) fetching card from address book ${ab.dirName} for ${emailAddress}`); |
|
|
|
} |
|
|
|
} |
|
|
|
return result; |
|
|
|