Open Bug 1734900 Opened 9 months ago Updated 5 months ago

Opening PDF attachments: "Always ask" dialog should have a radio option "Open with Thunderbird" (like FF)

Categories

(Thunderbird :: Preferences, enhancement, P3)

Thunderbird 91
enhancement

Tracking

(Not tracked)

People

(Reporter: kanlukasz, Unassigned)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

Attachments

(2 files)

Attached image tt.png

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:93.0) Gecko/20100101 Firefox/93.0

Steps to reproduce:

Settings -> Files & Attach -> Content Type -> PDF

Actual results:

In the current possibilities, we can set "Always ask" or "Preview in Thunderbird".

So we can't use "Always ask" and then decide if we want to open PDF directly in TB or use an external PDF program.

It's a bit inconvenient

Expected results:

Since I'm not sure if I can explain it vividly, I attach a picture with an example that shows in a comprehensive way what I mean

Windows 10
Thunderbird version : 91.5.0

Testing:
Changed Preferences for pdf to 'Always Ask'

Select to open pdf attachment - a window opens asking what to do.
Select 'Open With' and click on drop down which offers 'Adobe Acrobat (default)' and 'Other'.
I click on 'Other' - see larger list which includes Thunderbird.

Select 'Thunderbird' then it opens a new 'Write' window and the pdf is shown as an attachment.
Obviously this is not desired.

Select to open again - I now see 'Adobe Acrobat', 'Thunderbird' and 'Other'
'Other' offers quite a list including 'Firefox'
This does open the pdf in a new Firefox tab.
OK, I can read the pdf.

Select to open again - I now see 'Adobe Acrobat', 'Firefox' and 'Other'
So at least the list gets populated with the default - adobe and also the last selected option.
That's good.

Result:
You would expect the 'Thunderbird' option to do the same as the 'Firefox' option - open pdf to read in a new tab in Thunderbird, but it does not and it does not offer 'Preview in Thunderbird'.

'Preview in Thunderbird' option can only be set up for pdf in the Preferences > General
But if someone needs to sometimes open in Adobe or other pdf software they would select 'Always Ask' and this would be ok, but would discover it impossible to select 'Preview in Thunderbird' for other occasions.

Thank you kanlukasz for filing this, and thank you Anje for following up! I had seen this too in my testing and found it weird. More so given that Firefox does the right thing, to also offer "Open in Firefox" in the dialog when Always ask is chosen for PDF (see attachment 9245019 [details] in comment 0).

We should definitely try to port this over this over from Firefox (https://hg.mozilla.org/mozilla-central/rev/5946b607dbdd892681f3cfb98dcdee805c26140e per Mark's comment below).

I see that Firefox does the same for other things like images which can be viewed with FF, which might be interesting for TB, too - I find nothing wrong with opening images received right there in a Thunderbird tab for those who prefer that.

Judging from Mark's comment on the other bug, looks like this depends on notorious bug 1698140 (10 duplicates and counting).

(In reply to Mark Banner (:standard8) from bug 1667549 comment #2)

The default there is probably the default from the operating system. Unfortunately we can't do much about what your operating system reports.

I think there's two things that Thunderbird probably wants to do:

  1. Add the "Open in Thunderbird" option to the external handler, similar to what Firefox did in https://hg.mozilla.org/mozilla-central/rev/5946b607dbdd892681f3cfb98dcdee805c26140e - I just tried it but it didn't work because the attachment is seen as HTML.

  2. Adjust the compose window handler to open pdfs directly in a new tab - unfortunately the UX may be a little strange there as you'd be opening a new window or switching back to an old one.

Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(richard.marti)
Priority: -- → P3
Summary: Opening PDF - "Always ask" option should include option "Preview in Thunderbird" → Opening PDF attachments: "Always ask" dialog should have a radio option "Preview in Thunderbird" (like FF)

(In reply to Thomas D. (:thomas8) from comment #2)

Judging from Mark's comment on the other bug, looks like this depends on notorious bug 1698140 (10 duplicates and counting).

(In reply to Mark Banner (:standard8) from bug 1667549 comment #2)

I think there's two things that Thunderbird probably wants to do:

  1. Add the "Open in Thunderbird" option to the external handler, similar to what Firefox did in https://hg.mozilla.org/mozilla-central/rev/5946b607dbdd892681f3cfb98dcdee805c26140e - I just tried it but it didn't work because the attachment is seen as HTML.
Depends on: 1698140
Flags: needinfo?(richard.marti)
Blocks: 1667549
Attached image openInTB.png

On Daily adding the pref browser.helperApps.showOpenOptionForPdfJS works for me.

(In reply to Richard Marti (:Paenglab) from comment #4)

On Daily adding the pref browser.helperApps.showOpenOptionForPdfJS works for me.

Awesome, Richard, you rock!
However, selecting Open with Daily and then kicking OK does not open the PDF attachment for me (from message reader) - does this work for you?
The next thing to try is if "do this automatically" would work for "open with daily".

Flags: needinfo?(richard.marti)

No, it doesn't work and I get following error:
Exception { name: "NS_ERROR_ILLEGAL_VALUE", message: "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIMIMEInfo.launchWithFile]", result: 2147942487, filename: "chrome://messenger/content/msgHdrView.js", lineNumber: 2259, columnNumber: 0, data: null, stack: "_openTemporaryFile@chrome://messenger/content/msgHdrView.js:2259:14\nsaveAndOpen@chrome://messenger/content/msgHdrView.js:2178:14\n", location: XPCWrappedNative_NoHelper }
​columnNumber: 0
​data: null
​filename: "chrome://messenger/content/msgHdrView.js"
​lineNumber: 2259
​location: XPCWrappedNative_NoHelper { QueryInterface: QueryInterface(), filename: Getter, name: Getter, … }
​message: "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIMIMEInfo.launchWithFile]"
​name: "NS_ERROR_ILLEGAL_VALUE"
​result: 2147942487
​stack: "_openTemporaryFile@chrome://messenger/content/msgHdrView.js:2259:14\nsaveAndOpen@chrome://messenger/content/msgHdrView.js:2178:14\n"
​<prototype>: ExceptionPrototype { toString: toString(), name: Getter, message: Getter, … }

Flags: needinfo?(richard.marti)

(In reply to Thomas D. (:thomas8) from comment #5)

(In reply to Richard Marti (:Paenglab) from comment #4)

On Daily adding the pref browser.helperApps.showOpenOptionForPdfJS works for me.

Awesome, Richard, you rock!
However, selecting Open with Daily and then kicking OK does not open the PDF attachment for me (from message reader)

Fails with this error message:

Uncaught (in promise) 
Exception { name: "NS_ERROR_ILLEGAL_VALUE", message: "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIMIMEInfo.launchWithFile]", result: 2147942487, filename: "chrome://messenger/content/msgHdrView.js", lineNumber: 2259, columnNumber: 0, data: null, stack: "_openTemporaryFile@chrome://messenger/content/msgHdrView.js:2259:14\nsaveAndOpen@chrome://messenger/content/msgHdrView.js:2178:14\nasync*setDownloadToLaunch@chrome://messenger/content/msgHdrView.js:2232:19\nonOK@resource://gre/modules/HelperAppDlg.jsm:1103:26\nhandleEvent@resource://gre/modules/HelperAppDlg.jsm:1145:14\n_fireButtonEvent@chrome://global/content/elements/dialog.js:495:19\n_doButtonCommand@chrome://global/content/elements/dialog.js:474:29\n_handleButtonCommand@chrome://global/content/elements/dialog.js:468:19\nEventListener.handleEvent*_configureButtons@chrome://global/content/elements/dialog.js:369:16\nconnectedCallback@chrome://global/content/elements/dialog.js:163:12\n@chrome://global/content/customElements.js:217:21\nEventListener.handleEvent*@chrome://global/content/customElements.js:209:10\n@chrome://global/content/customElements.js:861:3\nobserve@resource://gre/modules/CustomElementsListener.jsm:26:31\n", location: XPCWrappedNative_NoHelper }
​
columnNumber: 0
​
data: null
​
filename: "chrome://messenger/content/msgHdrView.js"
​
lineNumber: 2259
​
location: XPCWrappedNative_NoHelper { QueryInterface: QueryInterface(), filename: Getter, name: Getter, … }
​
message: "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIMIMEInfo.launchWithFile]"
​
name: "NS_ERROR_ILLEGAL_VALUE"
​
result: 2147942487
​
stack: "_openTemporaryFile@chrome://messenger/content/msgHdrView.js:2259:14\nsaveAndOpen@chrome://messenger/content/msgHdrView.js:2178:14\nasync*setDownloadToLaunch@chrome://messenger/content/msgHdrView.js:2232:19\nonOK@resource://gre/modules/HelperAppDlg.jsm:1103:26\nhandleEvent@resource://gre/modules/HelperAppDlg.jsm:1145:14\n_fireButtonEvent@chrome://global/content/elements/dialog.js:495:19\n_doButtonCommand@chrome://global/content/elements/dialog.js:474:29\n_handleButtonCommand@chrome://global/content/elements/dialog.js:468:19\nEventListener.handleEvent*_configureButtons@chrome://global/content/elements/dialog.js:369:16\nconnectedCallback@chrome://global/content/elements/dialog.js:163:12\n@chrome://global/content/customElements.js:217:21\nEventListener.handleEvent*@chrome://global/content/customElements.js:209:10\n@chrome://global/content/customElements.js:861:3\nobserve@resource://gre/modules/CustomElementsListener.jsm:26:31\n"
​
<prototype>: ExceptionPrototype { toString: toString(), name: Getter, message: Getter, … }
msgHdrView.js:2259
    setDownloadToLaunch chrome://messenger/content/msgHdrView.js:2232
    AsyncFunctionThrow self-hosted:746
    (Async: async)
    onOK resource://gre/modules/HelperAppDlg.jsm:1103
    handleEvent resource://gre/modules/HelperAppDlg.jsm:1145
    _fireButtonEvent chrome://global/content/elements/dialog.js:495
    _doButtonCommand chrome://global/content/elements/dialog.js:474
    _handleButtonCommand chrome://global/content/elements/dialog.js:468
    _handleButtonCommand self-hosted:1225
    (Async: EventListener.handleEvent)
    _configureButtons chrome://global/content/elements/dialog.js:369
    connectedCallback chrome://global/content/elements/dialog.js:163
    <anonymous> chrome://global/content/customElements.js:217
    (Async: EventListener.handleEvent)
    <anonymous> chrome://global/content/customElements.js:209
    <anonymous> chrome://global/content/customElements.js:861
    observe resource://gre/modules/CustomElementsListener.jsm:26

As seen on screenshot of comment 4, for ease and ux-consistency in the dialog, this option should just be called "Open in Thunderbird". Not sure why we even have "Preview in TB" in the prefs, it's more than preview, and other differences aren't relevant enough to justify the different label. Iirc, you can now even fill pdf forms in FF and TB. Haven't tried that yet.

Summary: Opening PDF attachments: "Always ask" dialog should have a radio option "Preview in Thunderbird" (like FF) → Opening PDF attachments: "Always ask" dialog should have a radio option "Open with Thunderbird" (like FF)

Mark, you implemented the pdfjs into TB. Maybe you know what isn't working here? See the error when trying to open a PDF with the ask dialog after setting browser.helperApps.showOpenOptionForPdfJS to true.

Flags: needinfo?(standard8)

(In reply to Richard Marti (:Paenglab) from comment #9)

Mark, you implemented the pdfjs into TB. Maybe you know what isn't working here? See the error when trying to open a PDF with the ask dialog after setting browser.helperApps.showOpenOptionForPdfJS to true.

Were you testing in 91? That has an error so that it doesn't display the option, but that appears to have been fixed by bug 1749757 already.

However, with that fixed there's then an error thrown here: https://searchfox.org/comm-central/rev/44aa77c6da7c13b659667b96eb3c149e2096d0f1/mail/base/content/msgHdrView.js#2259

Looking back up the stack, it appears that this needs to actually handle the handleInternally flag: https://searchfox.org/comm-central/rev/44aa77c6da7c13b659667b96eb3c149e2096d0f1/mail/base/content/msgHdrView.js#2231-2233

I think if you can get the attachment url from further up (this.url, but this probably won't work there), then when handleInterally is true you should be able to do something like:

                tabmail.openTab("contentTab", {
                  url,
                  background: false,
                  linkHandler: "single-page",
                });
Flags: needinfo?(standard8)

(In reply to Mark Banner (:standard8) from comment #10)

Were you testing in 91? That has an error so that it doesn't display the option, but that appears to have been fixed by bug 1749757 already.

On Daily.

However, with that fixed there's then an error thrown here: https://searchfox.org/comm-central/rev/44aa77c6da7c13b659667b96eb3c149e2096d0f1/mail/base/content/msgHdrView.js#2259

Looking back up the stack, it appears that this needs to actually handle the handleInternally flag: https://searchfox.org/comm-central/rev/44aa77c6da7c13b659667b96eb3c149e2096d0f1/mail/base/content/msgHdrView.js#2231-2233

I think if you can get the attachment url from further up (this.url, but this probably won't work there), then when handleInterally is true you should be able to do something like:

                tabmail.openTab("contentTab", {
                  url,
                  background: false,
                  linkHandler: "single-page",
                });

Thanks for the pointers but unfortunately I don't know enough to make this work.

You need to log in before you can comment on or make changes to this bug.