Closed Bug 1882574 Opened 1 year ago Closed 9 months ago

Refactor outgoing message server support

Categories

(Thunderbird :: General, task)

Tracking

(thunderbird_esr115 wontfix)

RESOLVED FIXED
127 Branch
Tracking Status
thunderbird_esr115 --- wontfix

People

(Reporter: babolivier, Assigned: babolivier)

References

Details

Attachments

(2 files)

Thunderbird's code dealing with outgoing servers is built around the fact that the only outgoing server type is SMTP. In order to support EWS in Thunderbird, we need to make the related interfaces more generic, in order to build a EWS-specific implementation.

Summary: Refactor outgoing server support → Refactor outgoing message server support

There are a few steps remaining before this patch is ready for review:

  • Remove assumptions that the outgoing server is implemented in JavaScript
  • Audit the nsIMsgOutgoingServer interface to see what more can be decluttered and generalised

Eventually we'll also want to migrate the prefs so they don't use "smtp" in their names if the server doesn't actually use SMTP, but that will likely come in a second step.

Attachment #9389752 - Attachment description: WIP: Bug 1882574 - Enable outgoing message servers other than SMTP. → Bug 1882574 - Enable outgoing message servers other than SMTP. r=#thunderbird-reviewers

Pushed by vineet@thunderbird.net:
https://hg.mozilla.org/comm-central/rev/fa1090b30f09
Enable outgoing message servers other than SMTP. r=leftmostcat

Status: ASSIGNED → RESOLVED
Closed: 9 months ago
Resolution: --- → FIXED

Drive-by comment: Why did you introduce AUTF8String getPasswordWithUI(in AUTF8String promptString, in AUTF8String promptTitle);
https://hg.mozilla.org/comm-central/rev/fa1090b30f09ec14a166cd03fc2e8148f0ca9975#l47.209
when the incoming side has AString getPasswordWithUI(in AString aPromptString, in AString aPromptTitle);, see:
https://searchfox.org/comm-central/rev/ab3823fb293b4457b8e747b4b661bd59520cd314/mailnews/base/public/nsIMsgIncomingServer.idl#130

Using an UTF-16 API will save UTF-8 to UTF-16 and vice versa conversations at runtime since native JS strings are UTF-16, but would be passed through the API as UTF-8. Or am I missing something?

Flags: needinfo?(brendan)

There is no guarantee that a future implementation of this class will be in JavaScript, and in fact this is pretty much prep work to support an initial version of sending emails via EWS using a Rust implementation. Therefore we need to have some form of guarantee that, when crossing over the XPC boundary, the strings will use the correct encoding and highest level of compatibility, without putting the burden on the non-JS implementation (or its platform-specific bindings) or its non-JS consumers.

In Rust, wstring is represented as *const i16, which is as far from idiomatic as you can imagine; and AString means any operation, even one that doesn't cross the XPC boundary, triggers a UTF-8 <-> UTF-16 conversion. AUTF8String provides a satisfying guarantee in that regard, without having to convert over-eagerly (since the conversion only happens across the boundary, when it's necessary), or place the code generating or using these strings in charge of converting for a different platform.

I agree that it's not ideal to create a divergence with the incoming side, but imo this should be fixed by updating the incoming interface.

Flags: needinfo?(brendan)

and AString means any operation, even one that doesn't cross the XPC boundary, triggers a UTF-8 <-> UTF-16 conversion.

Thanks for the information. But the line above applies to Rust, not JS, correct? So Rust doesn't have a "native" char16_t-based string type? Looks like there is a utf16string crate providing WString, etc.

(In reply to Yury from comment #5)

and AString means any operation, even one that doesn't cross the XPC boundary, triggers a UTF-8 <-> UTF-16 conversion.

Thanks for the information. But the line above applies to Rust, not JS, correct?

Rust and C++, but not JS, correct.

So Rust doesn't have a "native" char16_t-based string type? Looks like there is a utf16string crate providing WString, etc.

Sure, but since the native string encoding is UTF-8, you'd still end up with the same issue as using AString, meaning every time you need to instantiate, manipulate, or output the string, you'd still be converting.

Generally speaking, AUTF8String allows us to use idiomatic string encoding in all three languages that make up Thunderbird (UTF8 in C++ and Rust, UTF16 in JS), and with a minimal amount of conversions while providing a guarantee that conversions happen when they're needed. So I see using it as an improvement for any interface which implementations are expected to go anywhere near JS (including its consumers).

Attachment #9401104 - Attachment description: Bug 1882574 - Follow-up: fix a call site for initFromOutgoing. r=#thunderbird-reviewers → Bug 1882574 - Follow-up: fix a missing call site for initFromOutgoing. r=#thunderbird-reviewers
Blocks: 1896171
Status: RESOLVED → REOPENED
Resolution: FIXED → ---

Pushed by martin@humanoids.be:
https://hg.mozilla.org/comm-central/rev/f761e605e19a
Follow-up: fix a missing call site for initFromOutgoing. r=leftmostcat

Status: REOPENED → RESOLVED
Closed: 9 months ago9 months ago
Resolution: --- → FIXED

Attached file Bug 1882574 - Follow-up: fix a missing call site for initFromOutgoing. r=#thunderbird-reviewers — Details

My issue is fixed in today's daily. Thanks!

Great, thanks for flagging it Wayne!

Target Milestone: --- → 127 Branch
Regressions: 1897924
Regressions: 1914662
No longer regressions: 1914662
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: