Closed Bug 1697669 Opened 3 months ago Closed 2 months ago

Add Outlook address book provider to preferences but not UI

Categories

(Thunderbird :: Address Book, enhancement)

enhancement

Tracking

(thunderbird_esr78 wontfix)

RESOLVED FIXED
89 Branch
Tracking Status
thunderbird_esr78 --- wontfix

People

(Reporter: darktrojan, Assigned: darktrojan)

References

Details

Attachments

(1 file)

The Mac OS address book provider can be enabled or disabled from the menu of the Address Book window. Now that the Outlook provider is up to speed, I'm going to do the same for it, but leave it disabled by default until more testing is complete.

Thanks. Please CC us on bugs in this area, we're happy to help.

Comment on attachment 9208296 [details]
Bug 1697669 - Add Outlook address book provider to preferences and UI. r?mkmelin

This is all pretty straightforward, but I'm looking for a good way to implement the function AbOutlookAddressBookCanExist. As you can see I've commented out what I first thought of doing, and that's because running that code causes a warning message to appear if Outlook is not installed. Can you suggest something to go here? It needs to be as simple and as fast as possible because it runs when a user opens the menu. We can add something to nsAbOutlookInterface if necessary.

Attachment #9208296 - Flags: feedback?(it)

Oh, and I've also moved the prefs from ldap_2.servers.oe to ldap_2.servers.outlook so you might need to check what you have before testing.

It will, but mozillaZine is not ours to update.

Geoff, Outlook 2010 for Windows can be installed on a ChromeOS, GNU/Linux and macOS operating systems. Can menu items please also be available for these operating systems too?

GNU/Linux: WineHQ with either PlayOnLinux or CrossOver Linux.

macOS: WineHQ with either PlayOnMac or CrossOver Mac.

What do you think?

Thank you

We'll take a closer look later. At first glance we have a question. Why:

pref("ldap_2.servers.outlook.uri", "moz-aboutlookdirectory:///");
pref("ldap_2.servers.outlook.description", "chrome://messenger/locale/addressbook/addressBook.properties");
pref("ldap_2.servers.outlook.dirType", -1);

We followed the "published" settings of

Add the string preference ldap_2.servers.Outlook.description, setting it to "Outlook"
Add the integer preference ldap_2.servers.Outlook.dirType, settiung it to 3.
Add the string preference ldap_2.servers.Outlook.uri, setting it to "moz-aboutlookdirectory://op/". Thunderbird version 87 and later: "moz-aboutlookdirectory:///". 

We've just checked again and there is positively no ldap_2.servers.oe.* set, so what did that do? Looking at
https://searchfox.org/comm-central/rev/39fe2d503a1960159f87969e563bd987938e0ca4/mailnews/addrbook/modules/AddrBookManager.jsm#331
it set some other prefs ldap_2.servers.oe.* but it's not clear where they were used later. I leave it to you whether you want to spell Outlook upper or lower case.

It's not set because you removed it with remains of the Outlook Express capability.

You could actually call the prefs anything you like beginning with ldap_2.servers.. I'm choosing to use a lower-case o because the convention (not always followed) is to use lower-case names for prefs.

Again, we don't run mozillaZine, and it's not official documentation.

What was removed was controlled by #ifdef MOZ_SUITE so factually, we didn't remove anything from TB. We'd still be curious to know what effect the remaining ldap_2.servers.oe had that you're now renaming. Everything is working in the checked-in state with the pref values from comment #8. We've just quoted mozillaZine to show you which settings we've used during development. That was our point of departure.

Comment on attachment 9208296 [details]
Bug 1697669 - Add Outlook address book provider to preferences and UI. r?mkmelin

Sorry, we had some "heavy lifting" to do elsewhere and couldn't look at this earlier.

So we removed our prefs:
ldap_2.servers.Outlook.uri moz-aboutlookdirectory:///
ldap_2.servers.Outlook.description Outlook
ldap_2.servers.Outlook.dirType 3

and applied the patch after editing the "x" out of "moz-aboutlookxdirectory:///" in addressbook.js. In the address book window in the file menu we then see a "Use Outlook Address Book" entry. When checking it, we get this in the console:
JavaScript error: chrome://messenger/content/addressbook/addressbook.js, line 1120: NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS: [JavaScript Error: "too much recursion" {file: "resource:///modules/AddrBookManager.jsm" line: 211}]'[JavaScript
Error: "too much recursion" {file: "resource:///modules/AddrBookManager.jsm" line: 211}]' when calling method: [nsIAbManager::deleteAddressBook]

Looks like this MailServices.ab.deleteAddressBook(kOutlookDirectoryURI); will not work since you need to specify a decent URI here and there can be more than one OL AB.

Despite this, the OL AB is included in the tree view, so that's a plus.

From comment #8: Why is the dirType -1?

Finally, it still works here with the code below "Is Outlook installed" restored. The menu comes up quickly. The official check for whether OL is installed would entail a search in the Windows registry for these keys where HKXX is HKCU or HKLM:
HKXX\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\outlook.exe - Path or (default)
HKXX\SOFTWARE\Microsoft\Office\NN\Outlook\InstallRoot - Path
HKXX\SOFTWARE\WOW6432Node\Microsoft\Office\NN\Outlook\InstallRoot - Path
HKXX\SOFTWARE\Microsoft\Office\NN\Common\InstallRoot - Path
HKXX\SOFTWARE\WOW6432Node\Microsoft\Office\NN\Common\InstallRoot - Path
HKXX\SOFTWARE\Microsoft\Office\NN\ClickToRunStore\Applications - Outlook
HKXX\SOFTWARE\WOW6432Node\Microsoft\Office\NN\ClickToRunStore\Applications - Outlook
where NN is one of "12.0", "14.0", "15.0", "16.0". Note that 12.0 is Office 2007 which likely won't work.
Sounds like fun? Well, there is more fun. MAPI won't work if the bit-ness of Office/OL doesn't match the bit-ness of TB.
I guess you could limit the check to looking for those registry keys in a suitable loop and if you find one, OL is likely installed. On the machine here we see three of them:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE - Path and (default)
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\16.0\Outlook\InstallRoot - Path
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\16.0\ClickToRunStore\Applications - Outlook

What to do with the feedback request. You've got our feedback, it's a bit on the "not quite ready/working" side.

Attachment #9208296 - Flags: feedback?(it)

EDIT: Comment partly obsoleted by comment #13:

We can add something to nsAbOutlookInterface if necessary.

Any MAPI access will likely cause the warning you mentioned. Was that a Windows system warning? Can you quote the text or attach a screenshot? We haven't looked in detail where TB checks the presence of OL for import, perhaps some ideas can be taken from there. The import code appears to be a little twisted, maybe somewhere around here:
https://searchfox.org/comm-central/rev/1521d401a3a062ab9e445c77cb5d7f33291e3364/mailnews/import/src/nsImportService.cpp#249
https://searchfox.org/comm-central/rev/1521d401a3a062ab9e445c77cb5d7f33291e3364/mailnews/import/content/importDialog.js#433
https://searchfox.org/comm-central/search?q=AutoLocate&redirect=false
https://searchfox.org/comm-central/search?q=OUTLOOK2003_REGISTRY_KEY&redirect=false
or "near" nsOutlookImport.cpp?

EDIT: Oops, looks like the JS stuff only adds all the "modules" to the menu, on Windows we see Becky but we don't have that installed, but that's a "from file" import which prompts for a file/directory. We haven't worked out when and where the checking is done.

Off-topic: Looking around the code base, we also found remnants of Outlook Express:
https://searchfox.org/comm-central/search?q=outlook+express&path=&case=false&regexp=false
in particular oeImportMsgs.properties

Looks like this MailServices.ab.deleteAddressBook(kOutlookDirectoryURI); will not work ...

Won't that delete the OL AB for real? It's not readonly like the Mac AB.

OK, we've tried import on a machine without OL. The OL mail and address book import is offered, and when executing it, we get the standard Windows/system message: "There is no email program associated to perform the requested action. Please install a email program or, if one is already installed, create an association in the Default Programs in control panel". That means that there is no checking done at all in import, import just fails on first MAPI access.

So if you uncomment the code that is commented-out, you will get this message upon first MAPI access. To hide the menu when no OL is installed, you'll need to check the registry entries mentioned in comment #11.

EDIT: Nice example here:
https://searchfox.org/comm-central/rev/110f81a3ebc80d0279f9b563ca53a52a4a46366a/mail/base/modules/Windows8WindowFrameColor.jsm#21

Geoff, please let us know if you'd like us to move this forward.

As it happens I was about to get back to it. I've spoken to Magnus about this and he's made it pretty clear that he doesn't want the UI for enabling it. So all I really going to be able to do is add the preferences, which is still better than nothing.

Attachment #9208296 - Attachment description: Bug 1697669 - Add Outlook address book provider to preferences and UI → Bug 1697669 - Add Outlook address book provider to preferences and UI. r?mkmelin

Why the pref("ldap_2.servers.outlook.dirType", -1); - should that be 3 (MAPI_DIRECTORY_TYPE)? If you add the prefs, won't the Outlook access be always enabled? Or is the trick to change -1 to 3 to enable it?

It won't be enabled unless the value is 3.

(In reply to Geoff Lankow (:darktrojan) from comment #15)

As it happens I was about to get back to it. I've spoken to Magnus about this and he's made it pretty clear that he doesn't want the UI for enabling it. So all I really going to be able to do is add the preferences, which is still better than nothing.

Can the reason(s) why Magnus doesn't want the UI for enabling it please be provided?

We would appreciate knowing why it is pretty clear as it isn't clear to us.

Thank you

Duplicate of this bug: 83100

(In reply to Óvári from comment #18)

Can the reason(s) why Magnus doesn't want the UI for enabling it please be provided?

Flags: needinfo?(mkmelin+mozilla)

As I've written in other bug(s), the future of this address book provider is rather unclear. It's not clear at all it's something we want to support going forwards. So I don't want to encourage people to rely on it.

The whole technology is poorly documented (at MS) and deprecated at their side as well.
There would not appear to be a huge interest in it either. Yes, it's been kind of broken, but even so Telemetry says globally only 100 installations had bothered to even try it out with the hidden pref. What can I say, that is super, super low however you want to look at it.

Flags: needinfo?(mkmelin+mozilla)

With all due respect, that statement is rather biased. MAPI is documented MS here
https://docs.microsoft.com/en-us/office/client-developer/outlook/mapi/outlook-mapi-reference
How do you derive the statement that it's deprecated?
There are open-source working examples, https://github.com/stephenegriffin/mfcmapi, and commercial offers: https://www.dimastr.com/outspy/home.htm, and there is a supportive community (see: https://www.dimastr.com/outspy/contact.htm).

In our humble opinion, a desktop integration of TB with OL given the current platform stats (https://stats.thunderbird.net/#platlang, about 95% Windows) will be an important "selling point" for TB especially in today's day and age where may people are working in a home-office with OL for work and TB for private e-mail. It's no surprise that no one has tried a feature which was mostly broken (took 10 bugs to fix!) and whose configuration was hidden in some mozillaZine article.

All that said, looks like an add-on developer already added the necessary settings, so let's see how many users this add-on attracts:
https://addons.thunderbird.net/en-US/thunderbird/addon/outlook-address-book-enabler/

Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/bce97cadbfc4
Add Outlook address book provider to preferences. r=mkmelin

Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 89 Branch
Summary: Add Outlook address book provider to preferences and UI → Add Outlook address book provider to preferences but not UI
You need to log in before you can comment on or make changes to this bug.