Bug 1896171 - Part 3: Remove constraint on the server URI being an implementor of nsIMsgMailNewsUrl. r=leftmostcat,mkmelin

Differential Revision: https://phabricator.services.mozilla.com/D211259

--HG--
extra : rebase_source : 9158bfcbaef26e215bf9d0879cb34e165ff16c5c
This commit is contained in:
Brendan Abolivier 2024-06-20 11:53:34 +00:00
Родитель 7b527cdf32
Коммит 6c9529c2cc
2 изменённых файлов: 21 добавлений и 12 удалений

Просмотреть файл

@ -657,12 +657,24 @@ export class MessageSend {
}
}
if (isNSSError) {
const u = url.QueryInterface(Ci.nsIMsgMailNewsUrl);
let secInfo = null;
let location = null;
if (url instanceof Ci.nsIMsgMailNewsUrl) {
// Not all URLs implement nsIMsgMailNewsUrl. Ideally we should not
// share the security info with the consumer by stamping it onto the
// URL, but for now we do what we can with what we have.
secInfo = url.failedSecInfo;
location = url.asciiHostPort;
} else {
location = `${url.host}:${url.port}`;
}
this.notifyListenerOnTransportSecurityError(
null,
exitCode,
u.failedSecInfo,
u.asciiHostPort
secInfo,
location
);
}
this.notifyListenerOnStopSending(null, exitCode, null, null);
@ -1411,8 +1423,10 @@ class MsgDeliveryListener {
OnStopRunningUrl(url, exitCode) {
lazy.MsgUtils.sendLogger.debug(`OnStopRunningUrl; exitCode=${exitCode}`);
const mailUrl = url.QueryInterface(Ci.nsIMsgMailNewsUrl);
mailUrl.UnRegisterListener(this);
if (url instanceof Ci.nsIMsgMailNewsUrl) {
url.UnRegisterListener(this);
}
this._msgSend.sendDeliveryCallback(url, this._isNewsDelivery, exitCode);
}

Просмотреть файл

@ -175,19 +175,14 @@ impl EwsOutgoingServer {
xpcom_method!(server_uri => GetServerURI() -> *const nsIURI);
fn server_uri(&self) -> Result<RefPtr<nsIURI>, nsresult> {
let ews_url = self.ews_url.get();
let ews_url = ews_url.as_ref().ok_or_else(|| {
let ews_url = ews_url.ok_or_else(|| {
log::error!(
"tried retrieving a URI for the server before initializing it with an EWS URL"
);
Err::<(), _>(nserror::NS_ERROR_NOT_INITIALIZED)
})?;
// Build an ews:// URI for this server. We do this because the
// MessageSend module expects the URI to be QI-able into
// Ci.nsIMsgMailnewsUrl.
let username = self.username.borrow();
let host = ews_url.host_str().ok_or(nserror::NS_ERROR_FAILURE)?;
let url = nsCString::from(format!("ews://{username}@{host}"));
let url = nsCString::from(ews_url.as_str());
let io_service =
xpcom::get_service::<nsIIOService>(cstr::cstr!("@mozilla.org/network/io-service;1"))