Closed Bug 1800423 Opened 2 years ago Closed 1 year ago

Enforce full startup of Thunderbird, when message composer is opened via mailto: link, to ensure sane environment (and make add-ons work again)

Categories

(Thunderbird :: Add-Ons: General, defect)

Thunderbird 102
defect

Tracking

(thunderbird_esr102 wontfix, thunderbird_esr115 fixed, thunderbird121 wontfix, thunderbird122 wontfix)

RESOLVED FIXED
122 Branch
Tracking Status
thunderbird_esr102 --- wontfix
thunderbird_esr115 --- fixed
thunderbird121 --- wontfix
thunderbird122 --- wontfix

People

(Reporter: lubomir.bucek, Assigned: TbSync)

References

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36

Steps to reproduce:

When I start email client Thunderbird from any other program via command:

ShellExecute(GetDesktopWindow()->m_hWnd, "open", "mailto:anymail@anymail.com", NULL, NULL, SW_SHOWNORMAL);

Thunderbird Mail Window opens properly, but QuickText plugin is not accessible.

QuickText works only in a case, when the full main Thunderbird window is opened and running before ShellExecute(..."mailto:anymail@anymail.com" ...) is called.

This bug in Thunderbird is new, older versions worked properly.

Component: Mail Window Front End → Add-Ons: General
Summary: Quick text → QuickText add-on works only in a case, when the full main Thunderbird window is opened and running before
Flags: needinfo?(john)

I may have an idea, how to fix this. Will try to fix it for 115.

The reason is that add-on startup has been delayed until after the app is fully loaded.

The add-on startup notification is never send, when a composer is opened directly in composer-only mode. Would it be ok to start the main app + the composer, when a mailto: link is passed into thunderbird? What is the gain of not fully loading the app? For example would it not be beneficial to be able to check the send folder after the message has been sent?

I could imagine that other services could be missing as well in the composer-only mode.

Flags: needinfo?(john) → needinfo?(mkmelin+mozilla)

Good timing. I just landed a change that does exactly that. https://hg.mozilla.org/comm-central/rev/e0539a23f82b7e2c72e0475392ff7681302be5c7#l2.374

Flags: needinfo?(mkmelin+mozilla)

The mailto case seems untouched and is still:

case "mailto": {
            let xuri = cmdLine.resolveURI("mailto:" + remoteParams[0]);
            openURI(xuri);
            break;
          }

I would have changed it to:

case "mailto": {
            let xuri = cmdLine.resolveURI("mailto:" + remoteParams[0]);
            getOrOpen3PaneWindow().then(() => openURI(xuri);
            break;
          }

or something along those lines. Would that be ok?

Ah, yes I think that would make sense.
While theoretically you can compose without the 3pane... I'm not sure why you would do that.

When I started this Bug 1800423, I supposed Mozila repair Thuderbird.

When I started this Bug 1800423, I supposed Mozila repair Thuderbird.
Because html pages with <a href="Mailto:aaa@bbb.cc?subject=AAA">bla-bla-bla</a>

When I started this Bug 1800423, I supposed Mozila repair Thuderbird.
Because html pages with <a href="Mailto:aaa@bbb.cc?subject=AAA">bla-bla-bla</a>
makes the sam problem: Thunnderbird is opening new email without Quicktext.

Magnus, you are correct. With https://hg.mozilla.org/comm-central/rev/e0539a23f82b7e2c72e0475392ff7681302be5c7#l2.374 landed, I can already execute

thunderbird mailto:user@something.net

and the composer is opened after an application window has been created. Before closing this as fixed. I want to make sure we covered all cases.

Wenn I execute the above statement, we skip the remoteCommand section:
https://searchfox.org/comm-central/rev/1045fa69e30893e86041a615f0bdfd4bc78bfa21/mail/components/MessengerContentHandler.jsm#239-302

We also skip the chromeParam section:
https://searchfox.org/comm-central/rev/1045fa69e30893e86041a615f0bdfd4bc78bfa21/mail/components/MessengerContentHandler.jsm#304-327

We enter the uri section:
https://searchfox.org/comm-central/rev/1045fa69e30893e86041a615f0bdfd4bc78bfa21/mail/components/MessengerContentHandler.jsm#413-644

In the uri section we fall through to the last else statement which now calls getOrOpen3PaneWindow(). Because the try { ... } fails, we call openURI(cmdLine.resolveURI(uri)); in the catch(e) { ... } block.

That means we do not at all enter the mailto case in the remoteCommand section:
https://searchfox.org/comm-central/rev/1045fa69e30893e86041a615f0bdfd4bc78bfa21/mail/components/MessengerContentHandler.jsm#251-255

  1. What is the remoteCommand section for? How can I trigger that?
  2. The comment here may be misleading. Should we update it to

// This may be a regular filename. Attempt to use it to create a new empty message with attachment.
// Otherwise attempt to interpret it as a uri and try to open it (for example a mailto: uri)

?

Without investigating it, perhaps it's involved in the way to compose where you don't have mailto:. but -compose (For more privileges, like to specify attachments). See http://kb.mozillazine.org/Command_line_arguments_-_Thunderbird
Updating the comment sounds good.

Thanks Magnus. I tried to use -compose, that triggers this cpp code:
https://searchfox.org/comm-central/rev/f01fefe31f97220234524e77e6e6c637f82cbe9c/mailnews/compose/src/nsMsgComposeService.cpp#1373-1377

That IS another case where the compose window is opened stand alone and which suffers from the same issue (add-on startup not announced).

  1. cpp code is not really my area, could you point me to code which I could use to start up the main window before the compose window is opened?

  2. Or should we think about unifying entry points and move that out of the cpp file and handle it in MessengerContentHandler.jsm as well (it does end up there, but because cmdLine.preventDefault is set, nothing is done)?

  3. Do you have another idea, what the remoteCommand section in MessengerContentHandler.jsm is for and how can I trigger that?

Starting and waiting for the window in cpp would be difficult at best. It would indeed be much nicer if everything went through MessengerContentHandler.jsm
Sorry I don't know anything else about remoteCommand. Very possibly just old cruft that nobody dared to touch.

In C++ msvc (MFC):

In C++ msvc (MFC):
where m_Email is member CString

void CPrehledOp::OnBnClickedButtonEmail()
{
UpdateData(TRUE);

// start ThuinderBird
char strPrgFiles86[_MAX_DIR];
if(SHGetSpecialFolderPathA(this->m_hWnd, strPrgFiles86, CSIDL_PROGRAM_FILESX86, FALSE))
{
	STARTUPINFO				s_info;
	PROCESS_INFORMATION 	p_info;
	memset(&s_info, 0, sizeof(STARTUPINFO));
	memset(&p_info, 0, sizeof(PROCESS_INFORMATION));
	s_info.cb = sizeof(STARTUPINFO);
	//s_info.wShowWindow = SW_MINIMIZE; //DOES NOT WORK

	char strCurrentDirectory[_MAX_PATH];
	sprintf_s(strCurrentDirectory, "%s\\Mozilla Thunderbird", strPrgFiles86);

	char strCommandLine[_MAX_PATH];
	sprintf_s(strCommandLine, "%s\\thunderbird.exe", strCurrentDirectory);

	::CreateProcess(NULL, strCommandLine, NULL, NULL, 0, NORMAL_PRIORITY_CLASS, NULL, strCurrentDirectory, &s_info, &p_info);
}

// mailto
CString strMailTo = "mailto:";
strMailTo += m_Email;
ShellExecute(GetDesktopWindow()->m_hWnd, "open", strMailTo, NULL, NULL, SW_SHOWNORMAL);

}

Of course it does'nt solve a case, when you meet <a href="Mailto:aaa@bbb.cc?subject=AAA">bla-bla-bla</a> in browser...

So, just to clarify - is this bug about making sure that add-ons are started up when TB is opened via a mailto link?

If the answer is Yes, can the title be rephrased accordingly?

The fix for the reported issue is to enforce loading the full app before opening the message compose window. Will change the subject.

Summary: QuickText add-on works only in a case, when the full main Thunderbird window is opened and running before → Enforce full startup of Thunderbird, when message composer is opened via mailto: link, to ensure sane environment (and make add-ons work again)

Would be nice if this could be fixed. A lot of add-ons hook into the composer window and i'm sure, some people are womderimng, why their installed add-ons are not working if the use a mailto: link. At least one of my customers does.

Assignee: nobody → john
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true

Pushed by micah@thunderbird.net:
https://hg.mozilla.org/comm-central/rev/49efee0f33a1
Enforce full app startup for mailto: and file: url cmdLine parameters. r=mkmelin

Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Regressions: 1866915
Target Milestone: --- → 122 Branch

Comment on attachment 9365388 [details]
Bug 1800423 - Enforce full app startup for mailto: and file: url cmdLine parameters. r=mkmelin

[Approval Request Comment]
Regression caused by (bug #):
User impact if declined: Startups using mailto: and file: urls via command line will not start the full app, and add-ons will not work
Testing completed (on c-c, etc.): full beta cycle
Risk to taking this patch (and alternatives if risky):
If this is uplifted, Bug 1866915 has to be uplifted as well.

Attachment #9365388 - Flags: approval-comm-esr115?

Comment on attachment 9365388 [details]
Bug 1800423 - Enforce full app startup for mailto: and file: url cmdLine parameters. r=mkmelin

[Triage Comment]
Approved for esr115

Attachment #9365388 - Flags: approval-comm-esr115? → approval-comm-esr115+
See Also: → 1893962
See Also: → 1755576
Duplicate of this bug: 1755576
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: