Browse Source

P4TB-357: Skip Mac, Outlook and LDAP address books for now, they don't provide a stable ID.

1.1.101
Jorg Knobloch 2 years ago
parent
commit
c227e7f20a
1 changed files with 21 additions and 3 deletions
  1. +21
    -3
      addon/content/TbContacts.js

+ 21
- 3
addon/content/TbContacts.js View File

@ -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;


Loading…
Cancel
Save