Bug 1719413 - Init NntpModuleLoader.jsm and NntpService.jsm to start implementing NNTP in JS. r=mkmelin
Differential Revision: https://phabricator.services.mozilla.com/D119594 --HG-- extra : amend_source : a8db3944cf93faca4235f8a5222916ed91ef06a9
This commit is contained in:
Родитель
a1118dab00
Коммит
03830341a1
|
@ -330,6 +330,10 @@ pref("mailnews.reply_quoting_selection.multi_word", true);
|
||||||
pref("mailnews.smtp.jsmodule", false);
|
pref("mailnews.smtp.jsmodule", false);
|
||||||
pref("mailnews.smtp.loglevel", "Warn");
|
pref("mailnews.smtp.loglevel", "Warn");
|
||||||
|
|
||||||
|
// If true, NntpService.jsm is used. Otherwise, nsNntpService.cpp is used.
|
||||||
|
pref("mailnews.nntp.jsmodule", false);
|
||||||
|
pref("mailnews.nntp.loglevel", "Warn");
|
||||||
|
|
||||||
pref("mail.operate_on_msgs_in_collapsed_threads", false);
|
pref("mail.operate_on_msgs_in_collapsed_threads", false);
|
||||||
pref("mail.warn_on_collapsed_thread_operation", true);
|
pref("mail.warn_on_collapsed_thread_operation", true);
|
||||||
pref("mail.warn_on_shift_delete", true);
|
pref("mail.warn_on_shift_delete", true);
|
||||||
|
|
|
@ -0,0 +1,81 @@
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
const EXPORTED_SYMBOLS = ["NntpModuleLoader"];
|
||||||
|
|
||||||
|
var { ComponentUtils } = ChromeUtils.import(
|
||||||
|
"resource://gre/modules/ComponentUtils.jsm"
|
||||||
|
);
|
||||||
|
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether to use nsNntpService.cpp or NntpService.jsm. When
|
||||||
|
* `mailnews.nntp.jsmodule` is `true`, use NntpService.jsm.
|
||||||
|
*/
|
||||||
|
function NntpModuleLoader() {
|
||||||
|
try {
|
||||||
|
this.loadModule();
|
||||||
|
} catch (e) {
|
||||||
|
Cu.reportError(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var nntpJSModules = [
|
||||||
|
// moduleName, interfaceId, contractId
|
||||||
|
[
|
||||||
|
"NntpService",
|
||||||
|
"{b13db263-a219-4168-aeaf-8266f001087e}",
|
||||||
|
"@mozilla.org/messenger/nntpservice;1",
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
NntpModuleLoader.prototype = {
|
||||||
|
QueryInterface: ChromeUtils.generateQI(["nsIObserver"]),
|
||||||
|
|
||||||
|
observe() {
|
||||||
|
// Nothing to do here, just need the entry so this is instantiated.
|
||||||
|
},
|
||||||
|
|
||||||
|
loadModule() {
|
||||||
|
if (Services.prefs.getBoolPref("mailnews.nntp.jsmodule", false)) {
|
||||||
|
let registrar = Components.manager.QueryInterface(
|
||||||
|
Ci.nsIComponentRegistrar
|
||||||
|
);
|
||||||
|
|
||||||
|
for (let [moduleName, interfaceId, contractId] of nntpJSModules) {
|
||||||
|
// Load a module.
|
||||||
|
let scope = ChromeUtils.import(`resource:///modules/${moduleName}.jsm`);
|
||||||
|
scope.NSGetFactory = ComponentUtils.generateNSGetFactory([
|
||||||
|
scope[moduleName],
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Register a module.
|
||||||
|
let classId = Components.ID(interfaceId);
|
||||||
|
registrar.registerFactory(
|
||||||
|
classId,
|
||||||
|
"",
|
||||||
|
contractId,
|
||||||
|
lazyFactoryFor(scope, classId)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
dump("[NntpModuleLoader] Using NntpService.jsm\n");
|
||||||
|
} else {
|
||||||
|
dump("[NntpModuleLoader] Using nsNntpService.cpp\n");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
function lazyFactoryFor(backendScope, classID) {
|
||||||
|
return {
|
||||||
|
createInstance(aOuter, aIID) {
|
||||||
|
let realFactory = backendScope.NSGetFactory(classID);
|
||||||
|
return realFactory.createInstance(aOuter, aIID);
|
||||||
|
},
|
||||||
|
lockFactory(lock) {
|
||||||
|
let realFactory = backendScope.NSGetFactory(classID);
|
||||||
|
return realFactory.lockFactory(lock);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
const EXPORTED_SYMBOLS = ["NntpService"];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the mailnews.nntp.jsmodule pref to true to use this module.
|
||||||
|
*
|
||||||
|
* @implements {nsINntpService}
|
||||||
|
*/
|
||||||
|
class NntpService {
|
||||||
|
QueryInterface = ChromeUtils.generateQI(["nsINntpService"]);
|
||||||
|
|
||||||
|
getNewNews(server, uri, getOld, urlListener, msgWindow) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
NntpService.prototype.classID = Components.ID(
|
||||||
|
"{b13db263-a219-4168-aeaf-8266f001087e}"
|
||||||
|
);
|
|
@ -10,5 +10,11 @@ Classes = [
|
||||||
'contract_ids': ['@mozilla.org/autocomplete/search;1?name=news'],
|
'contract_ids': ['@mozilla.org/autocomplete/search;1?name=news'],
|
||||||
'jsm': 'resource:///modules/NewsAutoCompleteSearch.jsm',
|
'jsm': 'resource:///modules/NewsAutoCompleteSearch.jsm',
|
||||||
'constructor': 'NewsAutoCompleteSearch',
|
'constructor': 'NewsAutoCompleteSearch',
|
||||||
|
}, {
|
||||||
|
'cid': '{977853d0-7710-436d-8e80-e270ef52c17c}',
|
||||||
|
'contract_ids': ['@mozilla.org/messenger/nntp-module-loader;1'],
|
||||||
|
'jsm': 'resource:///modules/NntpModuleLoader.jsm',
|
||||||
|
'constructor': 'NntpModuleLoader',
|
||||||
|
'categories': {'profile-after-change': 'NntpModuleLoader'},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
|
@ -20,6 +20,8 @@ SOURCES += [
|
||||||
|
|
||||||
EXTRA_JS_MODULES += [
|
EXTRA_JS_MODULES += [
|
||||||
"NewsAutoCompleteSearch.jsm",
|
"NewsAutoCompleteSearch.jsm",
|
||||||
|
"NntpModuleLoader.jsm",
|
||||||
|
"NntpService.jsm",
|
||||||
]
|
]
|
||||||
|
|
||||||
XPCOM_MANIFESTS += [
|
XPCOM_MANIFESTS += [
|
||||||
|
|
Загрузка…
Ссылка в новой задаче