Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux: Investigate how to configure BB so it can send documents from LibreOffice or from a folder/deskop via "Sent To > Mail Recient" #85

Closed
Betterbird opened this issue Sep 30, 2022 · 16 comments

Comments

@Betterbird
Copy link
Owner

On newsgroup de.comm.software.mozilla.mailnews some discussion was started that TB 102.3.0 couldn't receive documents from LO to be sent to a mail recipient. However, various users have since reported that it does in fact work.

It doesn't appear to work for BB since there's some configuration missing. We're hoping to get some feedback from @Posi81 or @mfschumann as to what may be missing. Does it work in the Flatpak?

@mfschumann
Copy link
Contributor

I have done a quick test with the BB flatpak 102.3.1-bb18 under Gnome 42 on Fedora Silverblue 36.

When I try to send a document from LO a BB compose window is opened with the subject set to the filename of the document. What seems to be missing is that the document is attached to the mail. For the TB flatpak the behavior is identical. When calling flatpak run eu.betterbird.Betterbird -compose "attachment='/var/home/martin/tmp/somefilethatexists'" I get a warning that the file does not exist (although it does), so maybe the issue is related to the flatpak sandboxing. I'll try to debug.

@Betterbird
Copy link
Owner Author

Partial success:
Putting a betterbird.desktop into /usr/share/applications and editing /usr/share/applications/defaults.list to contain x-scheme-handler/mailto=betterbird.desktop has the effect that mailto links in FF now open in BB. I guess that was the easy part. The question remains how LO and Sent To > Mail Recipient have it configured.

@Betterbird
Copy link
Owner Author

Betterbird commented Oct 1, 2022

Using ps aux | grep thunder we saw that when attaching a document from LO while TB is the default client (via the Mint/Xfce "Preferred Applications" panel), this command is run:
/usr/lib/thunderbird/thunderbird -remote "xfeDoCommand(composeMessage,to='',cc='',bcc='',attachment='file:///home/xxxxx/Desktop/betterbird/application.ini',subject='noname')"
No idea where this is configured, however supported in the TB code here:
https://searchfox.org/comm-central/rev/bfefc713c577d1b7db4e06f16bd687ccb7875ea7/mail/components/MessengerContentHandler.jsm#256
That appears to be starting TB 78 on our old Mint 20 VM.

Running an equivalent command for BB, like:
/home/xxxxx/Desktop/betterbird102/betterbird -remote "xfeDoCommand(composeMessage,to='',cc='',bcc='',attachment='file:///home/xxxxx/Desktop/betterbird/application.ini',subject='noname')"
launches a compose window without the attachment.

Your attempts with -compose "attachment='/var/home/martin/tmp/somefilethatexists'" don't appear to reflect what LO calls. If we just configure betterbird -compose "%s" as default mail app, we see this command being executed:
betterbird -compose ?subject=noname&attach=file:///tmp/lu41567qh31by.tmp/lu41567qh31dx.tmp/noname.odt
Obviously the URL-query notation is not compatible with the -compose parameters, hence the integration via -remote instead. Also, trying to add an attachment via a mailto: URL (like the ?subject=) would be a security hole and doesn't work.

@Betterbird
Copy link
Owner Author

Looks like there is a script that changes one format to another. We have it at /usr/share/xfce4/exo/exo-compose-mail. Looks like this one here: https://www.apt-browse.org/browse/ubuntu/xenial/universe/amd64/libexo-1-0/0.10.7-1/file/usr/lib/x86_64-linux-gnu/xfce4/exo-1/exo-compose-mail-1

@Betterbird
Copy link
Owner Author

Summarising: On an old Mint system with TB 78 the following all works:

/usr/lib/thunderbird/thunderbird -remote "xfeDoCommand(composeMessage,attachment='file:///home/jorgk/Desktop/huhu.txt',subject='noname')"
/usr/lib/thunderbird/thunderbird -compose "attachment='file:///home/jorgk/Desktop/huhu.txt',subject=noname)"
betterbird -compose "attachment='file:///home/jorgk/Desktop/huhu.txt',subject=noname)"

What doesn't work is

betterbird -remote "xfeDoCommand(composeMessage,attachment='file:///home/jorgk/Desktop/huhu.txt',subject='noname')"

That also doesn't work on Windows.

@mfschumann
Copy link
Contributor

Even if you get the betterbird -remote call working from command line, for the integration with LO to work I think we additionally need to file a PR with LO, because they use a script that distinguishes between mail clients and has some special treatment for Thunderbird.

@Betterbird
Copy link
Owner Author

Thanks for digging this out. Fixing LO is a one liner, no? -remote is broken in TB as well (of course): https://bugzilla.mozilla.org/show_bug.cgi?id=1793323. So somehow the people who claim it's working here
https://www.thunderbird-mail.de/forum/thread/90511-thunderbird-102-geht-verschicken-eines-pdf-dokumentes-aus-libreoffice-oder-aus-e/?postID=504181#post504181
are triggering the code path where LO uses -compose.

@mfschumann
Copy link
Contributor

mfschumann commented Oct 3, 2022

When calling flatpak run eu.betterbird.Betterbird -compose "attachment='/var/home/martin/tmp/somefilethatexists'" I get a warning that the file does not exist (although it does), so maybe the issue is related to the flatpak sandboxing. I'll try to debug.

I found that indeed the error I got was caused by lacking permissions in the sandbox that the flatpak app runs in. According to flathub/org.mozilla.Thunderbird#263 the preferred solution to that issue (using 'Portals' for file access) would have to be implemented upstream in the TB code. At the moment it seems to be partially implemented, leading to incosistent behavior that I documented in the readme for the BB flatpak.

There is a work-around (giving BB access to /home), but applying that comes with the caveat that the user has to move its profile directory. So I am hesitant to generally apply that work-around for the published flatpak.

All in all, for the "Send mail" integration between LO and BB to work for the flatpak version, quite a list of things have to happen:

  1. LO adds Betterbird to the list of mail agents that are treated like Thunderbird
  2. TB/BB upstream repairs the functionality of the -remote "xfeDoCommand(composeMessage,attachment=... call
  3. TB/BB upstream fixes the file permission issue described above by using 'Portals' everywhere

@Betterbird
Copy link
Owner Author

  1. https://bugs.documentfoundation.org/show_bug.cgi?id=151314 - Beyond our control
  2. https://bugzilla.mozilla.org/show_bug.cgi?id=1793323 - Will get fixed in the next BB release, either TB or we will fix.
  3. https://bugzilla.mozilla.org/show_bug.cgi?id=1786251 - Hmm, likely no quick fix, but there's a workaround.

We've only played with Mint/Xfce's "Preferred Programs" panel. That could be used to launch a BB compose window from a very old version of LO. We'll have to see what happens with Nr, 2 fixed even without Nr. 1.

@Betterbird
Copy link
Owner Author

TDF people suggested to provide a patch for Nr. 1. @mfschumann could you patch their senddoc.sh script and test it once a fix for Nr. 2 is available? Off-topic: You are one of the reporters of bug 799040 (Issues with ignored threads), well, that was fixed in BB a while ago with TB still not having picked up the patch.

@Betterbird
Copy link
Owner Author

  1. fixed in a594a0f

@mfschumann
Copy link
Contributor

Thanks, I will test your bugfix and try to patch LO's senddoc.sh locally. This may take some time because it seems that the script lands in the compiled binary, so I will need to set up the build first.

@Betterbird
Copy link
Owner Author

OK, in version 102.3.2-bb19 this works again:
/home/xxxxx/Desktop/betterbird/betterbird -remote "xfeDoCommand(composeMessage,to='h@h',cc='',bcc='',attachment='/home/xxxxx/Desktop/betterbird/application.ini',subject='noname')"

I thought of patching senddoc.sh locally, but if they baked it into the binary, I give up.

@mfschumann
Copy link
Contributor

This is my understanding of the code paths involved:
image

Your fix repairs the path where you end up in 5a, i.e., the user must manually set the mail client in LO. On the LO side this requires senddoc.sh to include betterbird in the list of Thunderbird-like clients. I've implemented that change locally, rebuilt the LO flatpak and confirmed that it calls betterbird Thunderbird-style instead via xdg-email. I will add that patch to the TDF issue.

For the code path ending in 5c, i.e., when the user does not specify the mail client within LO settings, there will probably be no fix because support of attaching files via mailto arguments is considered unsafe by TB upstream. Adding to that, there is also a proposal to drop support for attaching files in xdg-email .

For the flatpak versions of LO and BB the issue is even more complex due to the application sandboxing getting in the way when trying to call one app from within the other app's sandbox and sharing files between apps. Making the integration between flatpak'ed LO and BB work very probably requires either some manual work-arounds on the user side or changes to the LO code. Plus the result will be brittle because flatpak lacks a stable API to realize stuff like this. So I am not very inclined to push this topic any further.

@Betterbird
Copy link
Owner Author

Impressive investigation. However, the findings don't explain what I see in my old LO Writer 6.4.7.2 on Mint 20/Xfce, likely things have changed since then:

  1. No mail client configured in LO, Thunderbird configured as default maill app: Mail is sent via TB with the attachment, so we're not in 5c, in fact, via ps aux | grep thunder I can see 5a.
  2. BB configured in LO, Thunderbird configured as default maill app: Behaves the same as 1, although according to your diagram we should also get to 5c.
  3. BB configured as default mail app (regardless of setting in LO): Nothing happens.

But never mind, I have a very old version of LO and I don't know what the default e-mail configuration or xdg-mail do.

As far as LO is concerned, your patch in https://bugs.documentfoundation.org/show_bug.cgi?id=151314 looks good to me.

@fitojb
Copy link

fitojb commented Oct 10, 2022

@mfschumann I’ve merged your patch and will propose it for inclusion in the upcoming LO 7.4.3. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants