mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 11:47:58 +01:00
Port Xulmus/Muttator. Not tested yet.
This commit is contained in:
@@ -3,17 +3,13 @@
|
|||||||
// This work is licensed for reuse under an MIT license. Details are
|
// This work is licensed for reuse under an MIT license. Details are
|
||||||
// given in the LICENSE.txt file included with this file.
|
// given in the LICENSE.txt file included with this file.
|
||||||
|
|
||||||
function Addressbook() { //{{{
|
const Addressbook = Module("addressbook", {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
init: function () {
|
||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
},
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
|
||||||
|
|
||||||
const abManager = Cc["@mozilla.org/abmanager;1"].getService(Ci.nsIAbManager);
|
|
||||||
const rdf = Cc["@mozilla.org/rdf/rdf-service;1"].getService(Ci.nsIRDFService);
|
|
||||||
|
|
||||||
// TODO: add option for a format specifier, like:
|
// TODO: add option for a format specifier, like:
|
||||||
// :set displayname=%l, %f
|
// :set displayname=%l, %f
|
||||||
function generateDisplayName(firstName, lastName) {
|
generateDisplayName: function (firstName, lastName) {
|
||||||
if (firstName && lastName)
|
if (firstName && lastName)
|
||||||
return lastName + ", " + firstName;
|
return lastName + ", " + firstName;
|
||||||
else if (firstName)
|
else if (firstName)
|
||||||
@@ -22,150 +18,134 @@ function Addressbook() { //{{{
|
|||||||
return lastName;
|
return lastName;
|
||||||
else
|
else
|
||||||
return "";
|
return "";
|
||||||
}
|
},
|
||||||
|
|
||||||
function getDirectoryFromURI(uri) services.get("rdf").GetResource(uri).QueryInterface(Ci.nsIAbDirectory)
|
getDirectoryFromURI: function (uri) services.get("rdf").GetResource(uri).QueryInterface(Ci.nsIAbDirectory),
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
add: function (address, firstName, lastName, displayName) {
|
||||||
////////////////////// OPTIONS /////////////////////////////////////////////////
|
const personalAddressbookURI = "moz-abmdbdirectory://abook.mab";
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
let directory = this.getDirectoryFromURI(personalAddressbookURI);
|
||||||
|
let card = Cc["@mozilla.org/addressbook/cardproperty;1"].createInstance(Ci.nsIAbCard);
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
if (!address || !directory || !card)
|
||||||
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
return false;
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
|
||||||
|
|
||||||
var myModes = config.mailModes;
|
card.primaryEmail = address;
|
||||||
|
card.firstName = firstName;
|
||||||
|
card.lastName = lastName;
|
||||||
|
card.displayName = displayName;
|
||||||
|
|
||||||
mappings.add(myModes, ["a"],
|
return directory.addCard(card);
|
||||||
"Open a prompt to save a new addressbook entry for the sender of the selected message",
|
},
|
||||||
function () {
|
|
||||||
try {
|
// TODO: add telephone number support
|
||||||
var to = gDBView.hdrForFirstSelectedMessage.mime2DecodedAuthor;
|
list: function (filter, newMail) {
|
||||||
|
let addresses = [];
|
||||||
|
let dirs = abManager.directories;
|
||||||
|
let lowerFilter = filter.toLowerCase();
|
||||||
|
|
||||||
|
while (dirs.hasMoreElements()) {
|
||||||
|
let addrbook = dirs.getNext().QueryInterface(Ci.nsIAbDirectory);
|
||||||
|
let cards = addrbook.childCards;
|
||||||
|
while (cards.hasMoreElements()) {
|
||||||
|
let card = cards.getNext().QueryInterface(Ci.nsIAbCard);
|
||||||
|
//var mail = card.primaryEmail || ""; //XXX
|
||||||
|
let displayName = card.displayName;
|
||||||
|
if (!displayName)
|
||||||
|
displayName = this.generateDisplayName(card.firstName, card.lastName);
|
||||||
|
|
||||||
|
if (displayName.toLowerCase().indexOf(lowerFilter) > -1
|
||||||
|
|| card.primaryEmail.toLowerCase().indexOf(lowerFilter) > -1)
|
||||||
|
addresses.push([displayName, card.primaryEmail]);
|
||||||
}
|
}
|
||||||
catch (e) {
|
|
||||||
liberator.beep();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!to)
|
|
||||||
return;
|
|
||||||
|
|
||||||
let address = to.substring(to.indexOf("<") + 1, to.indexOf(">"));
|
|
||||||
|
|
||||||
let displayName = to.substr(0, to.indexOf("<") - 1);
|
|
||||||
if (/^\S+\s+\S+\s*$/.test(displayName)) {
|
|
||||||
let names = displayName.split(/\s+/);
|
|
||||||
displayName = "-firstname=" + names[0].replace(/"/g, "")
|
|
||||||
+ " -lastname=" + names[1].replace(/"/g, "");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
displayName = "-name=\"" + displayName.replace(/"/g, "") + "\"";
|
|
||||||
|
|
||||||
commandline.open(":", "contact " + address + " " + displayName, modes.EX);
|
|
||||||
});
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
|
||||||
////////////////////// COMMANDS ////////////////////////////////////////////////
|
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
|
||||||
|
|
||||||
commands.add(["con[tact]"],
|
|
||||||
"Add an address book entry",
|
|
||||||
function (args) {
|
|
||||||
let mailAddr = args[0]; // TODO: support more than one email address
|
|
||||||
let firstName = args["-firstname"] || null;
|
|
||||||
let lastName = args["-lastname"] || null;
|
|
||||||
let displayName = args["-name"] || null;
|
|
||||||
if (!displayName)
|
|
||||||
displayName = generateDisplayName(firstName, lastName);
|
|
||||||
|
|
||||||
if (addressbook.add(mailAddr, firstName, lastName, displayName))
|
|
||||||
liberator.echomsg("Added address: " + displayName + " <" + mailAddr + ">", 1, commandline.FORCE_SINGLELINE);
|
|
||||||
else
|
|
||||||
liberator.echoerr("Exxx: Could not add contact `" + mailAddr + "'", commandline.FORCE_SINGLELINE);
|
|
||||||
|
|
||||||
},
|
|
||||||
{
|
|
||||||
argCount: "+",
|
|
||||||
options: [[["-firstname", "-f"], commands.OPTION_STRING],
|
|
||||||
[["-lastname", "-l"], commands.OPTION_STRING],
|
|
||||||
[["-name", "-n"], commands.OPTION_STRING]]
|
|
||||||
});
|
|
||||||
|
|
||||||
commands.add(["contacts", "addr[essbook]"],
|
|
||||||
"List or open multiple addresses",
|
|
||||||
function (args) { addressbook.list(args.string, args.bang); },
|
|
||||||
{ bang: true });
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
|
||||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
|
||||||
|
|
||||||
return {
|
|
||||||
|
|
||||||
add: function (address, firstName, lastName, displayName) {
|
|
||||||
const personalAddressbookURI = "moz-abmdbdirectory://abook.mab";
|
|
||||||
let directory = getDirectoryFromURI(personalAddressbookURI);
|
|
||||||
let card = Cc["@mozilla.org/addressbook/cardproperty;1"].createInstance(Ci.nsIAbCard);
|
|
||||||
|
|
||||||
if (!address || !directory || !card)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
card.primaryEmail = address;
|
|
||||||
card.firstName = firstName;
|
|
||||||
card.lastName = lastName;
|
|
||||||
card.displayName = displayName;
|
|
||||||
|
|
||||||
return directory.addCard(card);
|
|
||||||
},
|
|
||||||
|
|
||||||
// TODO: add telephone number support
|
|
||||||
list: function (filter, newMail) {
|
|
||||||
let addresses = [];
|
|
||||||
let dirs = abManager.directories;
|
|
||||||
let lowerFilter = filter.toLowerCase();
|
|
||||||
|
|
||||||
while (dirs.hasMoreElements()) {
|
|
||||||
let addrbook = dirs.getNext().QueryInterface(Ci.nsIAbDirectory);
|
|
||||||
let cards = addrbook.childCards;
|
|
||||||
while (cards.hasMoreElements()) {
|
|
||||||
let card = cards.getNext().QueryInterface(Ci.nsIAbCard);
|
|
||||||
//var mail = card.primaryEmail || ""; //XXX
|
|
||||||
let displayName = card.displayName;
|
|
||||||
if (!displayName)
|
|
||||||
displayName = generateDisplayName(card.firstName, card.lastName);
|
|
||||||
|
|
||||||
if (displayName.toLowerCase().indexOf(lowerFilter) > -1
|
|
||||||
|| card.primaryEmail.toLowerCase().indexOf(lowerFilter) > -1)
|
|
||||||
addresses.push([displayName, card.primaryEmail]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (addresses.length < 1) {
|
|
||||||
if (!filter)
|
|
||||||
liberator.echoerr("Exxx: No contacts", commandline.FORCE_SINGLELINE);
|
|
||||||
else
|
|
||||||
liberator.echoerr("Exxx: No contacts matching string '" + filter + "'", commandline.FORCE_SINGLELINE);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newMail) {
|
|
||||||
// Now we have to create a new message
|
|
||||||
let args = {};
|
|
||||||
args.to = addresses.map(
|
|
||||||
function (address) "\"" + address[0].replace(/"/g, "") + " <" + address[1] + ">\""
|
|
||||||
).join(", ");
|
|
||||||
|
|
||||||
mail.composeNewMail(args);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
let list = template.tabular(["Name", "Address"], [],
|
|
||||||
[[util.clip(address[0], 50), address[1]] for ([, address] in Iterator(addresses))]
|
|
||||||
);
|
|
||||||
commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
//}}}
|
if (addresses.length < 1) {
|
||||||
} //}}}
|
if (!filter)
|
||||||
|
liberator.echoerr("Exxx: No contacts", commandline.FORCE_SINGLELINE);
|
||||||
|
else
|
||||||
|
liberator.echoerr("Exxx: No contacts matching string '" + filter + "'", commandline.FORCE_SINGLELINE);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newMail) {
|
||||||
|
// Now we have to create a new message
|
||||||
|
let args = {};
|
||||||
|
args.to = addresses.map(
|
||||||
|
function (address) "\"" + address[0].replace(/"/g, "") + " <" + address[1] + ">\""
|
||||||
|
).join(", ");
|
||||||
|
|
||||||
|
mail.composeNewMail(args);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let list = template.tabular(["Name", "Address"], [],
|
||||||
|
[[util.clip(address[0], 50), address[1]] for ([, address] in Iterator(addresses))]
|
||||||
|
);
|
||||||
|
commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
}, {
|
||||||
|
commands: function () {
|
||||||
|
commands.add(["con[tact]"],
|
||||||
|
"Add an address book entry",
|
||||||
|
function (args) {
|
||||||
|
let mailAddr = args[0]; // TODO: support more than one email address
|
||||||
|
let firstName = args["-firstname"] || null;
|
||||||
|
let lastName = args["-lastname"] || null;
|
||||||
|
let displayName = args["-name"] || null;
|
||||||
|
if (!displayName)
|
||||||
|
displayName = this.generateDisplayName(firstName, lastName);
|
||||||
|
|
||||||
|
if (addressbook.add(mailAddr, firstName, lastName, displayName))
|
||||||
|
liberator.echomsg("Added address: " + displayName + " <" + mailAddr + ">", 1, commandline.FORCE_SINGLELINE);
|
||||||
|
else
|
||||||
|
liberator.echoerr("Exxx: Could not add contact `" + mailAddr + "'", commandline.FORCE_SINGLELINE);
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
argCount: "+",
|
||||||
|
options: [[["-firstname", "-f"], commands.OPTION_STRING],
|
||||||
|
[["-lastname", "-l"], commands.OPTION_STRING],
|
||||||
|
[["-name", "-n"], commands.OPTION_STRING]]
|
||||||
|
});
|
||||||
|
|
||||||
|
commands.add(["contacts", "addr[essbook]"],
|
||||||
|
"List or open multiple addresses",
|
||||||
|
function (args) { addressbook.list(args.string, args.bang); },
|
||||||
|
{ bang: true });
|
||||||
|
},
|
||||||
|
mappings: function () {
|
||||||
|
var myModes = config.mailModes;
|
||||||
|
|
||||||
|
mappings.add(myModes, ["a"],
|
||||||
|
"Open a prompt to save a new addressbook entry for the sender of the selected message",
|
||||||
|
function () {
|
||||||
|
try {
|
||||||
|
var to = gDBView.hdrForFirstSelectedMessage.mime2DecodedAuthor;
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
liberator.beep();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!to)
|
||||||
|
return;
|
||||||
|
|
||||||
|
let address = to.substring(to.indexOf("<") + 1, to.indexOf(">"));
|
||||||
|
|
||||||
|
let displayName = to.substr(0, to.indexOf("<") - 1);
|
||||||
|
if (/^\S+\s+\S+\s*$/.test(displayName)) {
|
||||||
|
let names = displayName.split(/\s+/);
|
||||||
|
displayName = "-firstname=" + names[0].replace(/"/g, "")
|
||||||
|
+ " -lastname=" + names[1].replace(/"/g, "");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
displayName = "-name=\"" + displayName.replace(/"/g, "") + "\"";
|
||||||
|
|
||||||
|
commandline.open(":", "contact " + address + " " + displayName, modes.EX);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
// vim: set fdm=marker sw=4 ts=4 et:
|
// vim: set fdm=marker sw=4 ts=4 et:
|
||||||
|
|||||||
@@ -3,214 +3,185 @@
|
|||||||
// This work is licensed for reuse under an MIT license. Details are
|
// This work is licensed for reuse under an MIT license. Details are
|
||||||
// given in the LICENSE.txt file included with this file.
|
// given in the LICENSE.txt file included with this file.
|
||||||
|
|
||||||
const config = (function () { //{{{
|
const config = { //{{{
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/*** required options, no checks done if they really exist, so be careful ***/
|
||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
name: "Muttator",
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
hostApplication: "Thunderbird", // TODO: can this be found out otherwise? gBrandBundle.getString("brandShortName");
|
||||||
|
// Yes, but it will be localized unlike all other strings. So, it's best left until we i18n liberator. --djk
|
||||||
|
|
||||||
var name = "Muttator";
|
get mainWindowId() this.isComposeWindow ? "msgcomposeWindow" : "messengerWindow",
|
||||||
var host = "Thunderbird";
|
|
||||||
var tabmail;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/*** optional options, there are checked for existence and a fallback provided ***/
|
||||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
features: ["hints", "mail", "marks", "addressbook", "tabs"],
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
defaults: {
|
||||||
|
guioptions: "frb",
|
||||||
|
showtabline: 1,
|
||||||
|
titlestring: "Muttator"
|
||||||
|
},
|
||||||
|
|
||||||
return {
|
guioptions: {
|
||||||
/*** required options, no checks done if they really exist, so be careful ***/
|
m: ["MenuBar", ["mail-toolbar-menubar2"]],
|
||||||
name: name,
|
T: ["Toolbar" , ["mail-bar2"]],
|
||||||
hostApplication: host, // TODO: can this be found out otherwise? gBrandBundle.getString("brandShortName");
|
f: ["Folder list", ["folderPaneBox", "folderpane_splitter"]],
|
||||||
// Yes, but it will be localized unlike all other strings. So, it's best left until we i18n liberator. --djk
|
F: ["Folder list header", ["folderPaneHeader"]]
|
||||||
get mainWindowId() this.isComposeWindow ? "msgcomposeWindow" : "messengerWindow",
|
},
|
||||||
|
|
||||||
/*** optional options, there are checked for existence and a fallback provided ***/
|
get isComposeWindow() window.wintype == "msgcompose",
|
||||||
features: ["hints", "mail", "marks", "addressbook", "tabs"],
|
get browserModes() [modes.MESSAGE],
|
||||||
defaults: {
|
get mailModes() [modes.NORMAL],
|
||||||
guioptions: "frb",
|
// focusContent() focuses this widget
|
||||||
showtabline: 1,
|
get mainWidget() this.isComposeWindow ? document.getElementById("content-frame") : GetThreadTree(),
|
||||||
titlestring: name
|
get visualbellWindow() document.getElementById(this.mainWindowId),
|
||||||
},
|
styleableChrome: ["chrome://messenger/content/messenger.xul",
|
||||||
|
"chrome://messenger/content/messengercompose/messengercompose.xul"],
|
||||||
|
|
||||||
guioptions: {
|
autocommands: [["DOMLoad", "Triggered when a page's DOM content has fully loaded"],
|
||||||
m: ["MenuBar", ["mail-toolbar-menubar2"]],
|
["FolderLoad", "Triggered after switching folders in Thunderbird"],
|
||||||
T: ["Toolbar" , ["mail-bar2"]],
|
["PageLoadPre", "Triggered after a page load is initiated"],
|
||||||
f: ["Folder list", ["folderPaneBox", "folderpane_splitter"]],
|
["PageLoad", "Triggered when a page gets (re)loaded/opened"],
|
||||||
F: ["Folder list header", ["folderPaneHeader"]]
|
["MuttatorEnter", "Triggered after Thunderbird starts"],
|
||||||
},
|
["MuttatorLeave", "Triggered before exiting Thunderbird"],
|
||||||
|
["MuttatorLeavePre", "Triggered before exiting Thunderbird"]],
|
||||||
|
dialogs: [
|
||||||
|
["about", "About Thunderbird",
|
||||||
|
function () { window.openAboutDialog(); }],
|
||||||
|
["addons", "Manage Add-ons",
|
||||||
|
function () { window.openAddonsMgr(); }],
|
||||||
|
["addressbook", "Address book",
|
||||||
|
function () { window.toAddressBook(); }],
|
||||||
|
["checkupdates", "Check for updates",
|
||||||
|
function () { window.checkForUpdates(); }],
|
||||||
|
/*["cleardata", "Clear private data",
|
||||||
|
function () { Cc[GLUE_CID].getService(Ci.nsIBrowserGlue).sanitize(window || null); }],*/
|
||||||
|
["console", "JavaScript console",
|
||||||
|
function () { window.toJavaScriptConsole(); }],
|
||||||
|
/*["customizetoolbar", "Customize the Toolbar",
|
||||||
|
function () { BrowserCustomizeToolbar(); }],*/
|
||||||
|
["dominspector", "DOM Inspector",
|
||||||
|
function () { window.inspectDOMDocument(content.document); }],
|
||||||
|
["downloads", "Manage Downloads",
|
||||||
|
function () { window.toOpenWindowByType('Download:Manager', 'chrome://mozapps/content/downloads/downloads.xul', 'chrome,dialog=no,resizable'); }],
|
||||||
|
/*["import", "Import Preferences, Bookmarks, History, etc. from other browsers",
|
||||||
|
function () { BrowserImport(); }],
|
||||||
|
["openfile", "Open the file selector dialog",
|
||||||
|
function () { BrowserOpenFileWindow(); }],
|
||||||
|
["pageinfo", "Show information about the current page",
|
||||||
|
function () { BrowserPageInfo(); }],
|
||||||
|
["pagesource", "View page source",
|
||||||
|
function () { BrowserViewSourceOfDocument(content.document); }],*/
|
||||||
|
["preferences", "Show Thunderbird preferences dialog",
|
||||||
|
function () { openOptionsDialog(); }],
|
||||||
|
/*["printpreview", "Preview the page before printing",
|
||||||
|
function () { PrintUtils.printPreview(onEnterPrintPreview, onExitPrintPreview); }],*/
|
||||||
|
["printsetup", "Setup the page size and orientation before printing",
|
||||||
|
function () { PrintUtils.showPageSetup(); }],
|
||||||
|
["print", "Show print dialog",
|
||||||
|
function () { PrintUtils.print(); }],
|
||||||
|
["saveframe", "Save frame to disk",
|
||||||
|
function () { window.saveFrameDocument(); }],
|
||||||
|
["savepage", "Save page to disk",
|
||||||
|
function () { window.saveDocument(window.content.document); }],
|
||||||
|
/*["searchengines", "Manage installed search engines",
|
||||||
|
function () { openDialog("chrome://browser/content/search/engineManager.xul", "_blank", "chrome,dialog,modal,centerscreen"); }],
|
||||||
|
["selectionsource", "View selection source",
|
||||||
|
function () { buffer.viewSelectionSource(); }]*/
|
||||||
|
],
|
||||||
|
|
||||||
get isComposeWindow() window.wintype == "msgcompose",
|
focusChange: function (win) {
|
||||||
get browserModes() [modes.MESSAGE],
|
// we switch to -- MESSAGE -- mode for Muttator, when the main HTML widget gets focus
|
||||||
get mailModes() [modes.NORMAL],
|
if (win && win.document instanceof HTMLDocument || liberator.focus instanceof HTMLAnchorElement) {
|
||||||
// focusContent() focuses this widget
|
if (config.isComposeWindow)
|
||||||
get mainWidget() this.isComposeWindow ? document.getElementById("content-frame") : GetThreadTree(),
|
modes.set(modes.INSERT, modes.TEXTAREA);
|
||||||
get visualbellWindow() document.getElementById(this.mainWindowId),
|
else if (liberator.mode != modes.MESSAGE)
|
||||||
styleableChrome: ["chrome://messenger/content/messenger.xul",
|
liberator.mode = modes.MESSAGE;
|
||||||
"chrome://messenger/content/messengercompose/messengercompose.xul"],
|
|
||||||
|
|
||||||
autocommands: [["DOMLoad", "Triggered when a page's DOM content has fully loaded"],
|
|
||||||
["FolderLoad", "Triggered after switching folders in " + host],
|
|
||||||
["PageLoadPre", "Triggered after a page load is initiated"],
|
|
||||||
["PageLoad", "Triggered when a page gets (re)loaded/opened"],
|
|
||||||
[name + "Enter", "Triggered after " + host + " starts"],
|
|
||||||
[name + "Leave", "Triggered before exiting " + host],
|
|
||||||
[name + "LeavePre", "Triggered before exiting " + host]],
|
|
||||||
|
|
||||||
dialogs: [
|
|
||||||
["about", "About " + host,
|
|
||||||
function () { window.openAboutDialog(); }],
|
|
||||||
["addons", "Manage Add-ons",
|
|
||||||
function () { window.openAddonsMgr(); }],
|
|
||||||
["addressbook", "Address book",
|
|
||||||
function () { window.toAddressBook(); }],
|
|
||||||
["checkupdates", "Check for updates",
|
|
||||||
function () { window.checkForUpdates(); }],
|
|
||||||
/*["cleardata", "Clear private data",
|
|
||||||
function () { Cc[GLUE_CID].getService(Ci.nsIBrowserGlue).sanitize(window || null); }],*/
|
|
||||||
["console", "JavaScript console",
|
|
||||||
function () { window.toJavaScriptConsole(); }],
|
|
||||||
/*["customizetoolbar", "Customize the Toolbar",
|
|
||||||
function () { BrowserCustomizeToolbar(); }],*/
|
|
||||||
["dominspector", "DOM Inspector",
|
|
||||||
function () { window.inspectDOMDocument(content.document); }],
|
|
||||||
["downloads", "Manage Downloads",
|
|
||||||
function () { window.toOpenWindowByType('Download:Manager', 'chrome://mozapps/content/downloads/downloads.xul', 'chrome,dialog=no,resizable'); }],
|
|
||||||
/*["import", "Import Preferences, Bookmarks, History, etc. from other browsers",
|
|
||||||
function () { BrowserImport(); }],
|
|
||||||
["openfile", "Open the file selector dialog",
|
|
||||||
function () { BrowserOpenFileWindow(); }],
|
|
||||||
["pageinfo", "Show information about the current page",
|
|
||||||
function () { BrowserPageInfo(); }],
|
|
||||||
["pagesource", "View page source",
|
|
||||||
function () { BrowserViewSourceOfDocument(content.document); }],*/
|
|
||||||
["preferences", "Show " + host + " preferences dialog",
|
|
||||||
function () { openOptionsDialog(); }],
|
|
||||||
/*["printpreview", "Preview the page before printing",
|
|
||||||
function () { PrintUtils.printPreview(onEnterPrintPreview, onExitPrintPreview); }],*/
|
|
||||||
["printsetup", "Setup the page size and orientation before printing",
|
|
||||||
function () { PrintUtils.showPageSetup(); }],
|
|
||||||
["print", "Show print dialog",
|
|
||||||
function () { PrintUtils.print(); }],
|
|
||||||
["saveframe", "Save frame to disk",
|
|
||||||
function () { window.saveFrameDocument(); }],
|
|
||||||
["savepage", "Save page to disk",
|
|
||||||
function () { window.saveDocument(window.content.document); }],
|
|
||||||
/*["searchengines", "Manage installed search engines",
|
|
||||||
function () { openDialog("chrome://browser/content/search/engineManager.xul", "_blank", "chrome,dialog,modal,centerscreen"); }],
|
|
||||||
["selectionsource", "View selection source",
|
|
||||||
function () { buffer.viewSelectionSource(); }]*/
|
|
||||||
],
|
|
||||||
|
|
||||||
focusChange: function (win) {
|
|
||||||
// we switch to -- MESSAGE -- mode for Muttator, when the main HTML widget gets focus
|
|
||||||
if (win && win.document instanceof HTMLDocument || liberator.focus instanceof HTMLAnchorElement) {
|
|
||||||
if (config.isComposeWindow)
|
|
||||||
modes.set(modes.INSERT, modes.TEXTAREA);
|
|
||||||
else if (liberator.mode != modes.MESSAGE)
|
|
||||||
liberator.mode = modes.MESSAGE;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
getBrowser: function () {
|
|
||||||
if (!tabmail) {
|
|
||||||
tabmail = { __proto__: document.getElementById("tabmail") };
|
|
||||||
tabmail.__defineGetter__("mTabContainer", function () this.tabContainer);
|
|
||||||
tabmail.__defineGetter__("mTabs", function () this.tabContainer.childNodes);
|
|
||||||
tabmail.__defineGetter__("mCurrentTab", function () this.tabContainer.selectedItem);
|
|
||||||
tabmail.__defineGetter__("mStrip", function () this.tabStrip);
|
|
||||||
tabmail.__defineGetter__("browsers", function () [browser for (browser in Iterator(this.mTabs))]);
|
|
||||||
}
|
|
||||||
return tabmail;
|
|
||||||
},
|
|
||||||
|
|
||||||
// they are sorted by relevance, not alphabetically
|
|
||||||
helpFiles: ["intro.html", "version.html"],
|
|
||||||
|
|
||||||
get ignoreKeys() {
|
|
||||||
delete this.ignoreKeys;
|
|
||||||
return this.ignoreKeys = {
|
|
||||||
"<Return>": modes.NORMAL | modes.INSERT,
|
|
||||||
"<Space>": modes.NORMAL | modes.INSERT,
|
|
||||||
"<Up>": modes.NORMAL | modes.INSERT,
|
|
||||||
"<Down>": modes.NORMAL | modes.INSERT
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
modes: [
|
|
||||||
["MESSAGE", { char: "m" }],
|
|
||||||
["COMPOSE"]
|
|
||||||
],
|
|
||||||
|
|
||||||
// NOTE: as I don't use TB I have no idea how robust this is. --djk
|
|
||||||
get outputHeight() {
|
|
||||||
if (!this.isComposeWindow) {
|
|
||||||
let container = document.getElementById("tabpanelcontainer").boxObject;
|
|
||||||
let deck = document.getElementById("displayDeck");
|
|
||||||
let box = document.getElementById("messagepanebox");
|
|
||||||
let splitter = document.getElementById("threadpane-splitter").boxObject;
|
|
||||||
|
|
||||||
if (splitter.width > splitter.height)
|
|
||||||
return container.height - deck.minHeight - box.minHeight- splitter.height;
|
|
||||||
else
|
|
||||||
return container.height - Math.max(deck.minHeight, box.minHeight);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return document.getElementById("appcontent").boxObject.height;
|
|
||||||
},
|
|
||||||
|
|
||||||
scripts: [
|
|
||||||
"addressbook.js",
|
|
||||||
"compose/compose.js",
|
|
||||||
"mail.js",
|
|
||||||
"tabs.js"
|
|
||||||
],
|
|
||||||
|
|
||||||
// to allow Vim to :set ft=mail automatically
|
|
||||||
tempFile: "mutt-ator-mail",
|
|
||||||
|
|
||||||
init: function () {
|
|
||||||
// don't wait too long when selecting new messages
|
|
||||||
// GetThreadTree()._selectDelay = 300; // TODO: make configurable
|
|
||||||
|
|
||||||
// load Muttator specific modules
|
|
||||||
if (this.isComposeWindow)
|
|
||||||
// TODO: this should probably be "composer"
|
|
||||||
liberator.loadModule("compose", Compose);
|
|
||||||
else {
|
|
||||||
liberator.loadModule("mail", Mail);
|
|
||||||
liberator.loadModule("addressbook", Addressbook);
|
|
||||||
liberator.loadModule("tabs", Tabs);
|
|
||||||
liberator.loadModule("marks", Marks);
|
|
||||||
liberator.loadModule("hints", Hints);
|
|
||||||
}
|
|
||||||
|
|
||||||
commands.add(["pref[erences]", "prefs"],
|
|
||||||
"Show " + config.hostApplication + " preferences",
|
|
||||||
function () { window.openOptionsDialog(); },
|
|
||||||
{ argCount: "0" });
|
|
||||||
|
|
||||||
// FIXME: comment obviously incorrect
|
|
||||||
// 0: never automatically edit externally
|
|
||||||
// 1: automatically edit externally when message window is shown the first time
|
|
||||||
// 2: automatically edit externally, once the message text gets focus (not working currently)
|
|
||||||
options.add(["autoexternal", "ae"],
|
|
||||||
"Edit message with external editor by default",
|
|
||||||
"boolean", false);
|
|
||||||
|
|
||||||
options.add(["online"],
|
|
||||||
"Set the 'work offline' option",
|
|
||||||
"boolean", true,
|
|
||||||
{
|
|
||||||
setter: function (value) {
|
|
||||||
if (MailOfflineMgr.isOnline() != value)
|
|
||||||
MailOfflineMgr.toggleOfflineStatus();
|
|
||||||
return value;
|
|
||||||
},
|
|
||||||
getter: function () MailOfflineMgr.isOnline()
|
|
||||||
});
|
|
||||||
|
|
||||||
//}}}
|
|
||||||
}
|
}
|
||||||
}; //}}}
|
},
|
||||||
})(); //}}}
|
|
||||||
|
getBrowser: function () {
|
||||||
|
var tabmail = { __proto__: document.getElementById("tabmail") };
|
||||||
|
tabmail.__defineGetter__("mTabContainer", function () this.tabContainer);
|
||||||
|
tabmail.__defineGetter__("mTabs", function () this.tabContainer.childNodes);
|
||||||
|
tabmail.__defineGetter__("mCurrentTab", function () this.tabContainer.selectedItem);
|
||||||
|
tabmail.__defineGetter__("mStrip", function () this.tabStrip);
|
||||||
|
tabmail.__defineGetter__("browsers", function () [browser for (browser in Iterator(this.mTabs))]);
|
||||||
|
config.getBrowser = function () tabmail;
|
||||||
|
return tabmail;
|
||||||
|
},
|
||||||
|
|
||||||
|
// they are sorted by relevance, not alphabetically
|
||||||
|
helpFiles: ["intro.html", "version.html"],
|
||||||
|
|
||||||
|
get ignoreKeys() {
|
||||||
|
delete this.ignoreKeys;
|
||||||
|
return this.ignoreKeys = {
|
||||||
|
"<Return>": modes.NORMAL | modes.INSERT,
|
||||||
|
"<Space>": modes.NORMAL | modes.INSERT,
|
||||||
|
"<Up>": modes.NORMAL | modes.INSERT,
|
||||||
|
"<Down>": modes.NORMAL | modes.INSERT
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
modes: [
|
||||||
|
["MESSAGE", { char: "m" }],
|
||||||
|
["COMPOSE"]
|
||||||
|
],
|
||||||
|
|
||||||
|
// NOTE: as I don't use TB I have no idea how robust this is. --djk
|
||||||
|
get outputHeight() {
|
||||||
|
if (!this.isComposeWindow) {
|
||||||
|
let container = document.getElementById("tabpanelcontainer").boxObject;
|
||||||
|
let deck = document.getElementById("displayDeck");
|
||||||
|
let box = document.getElementById("messagepanebox");
|
||||||
|
let splitter = document.getElementById("threadpane-splitter").boxObject;
|
||||||
|
|
||||||
|
if (splitter.width > splitter.height)
|
||||||
|
return container.height - deck.minHeight - box.minHeight- splitter.height;
|
||||||
|
else
|
||||||
|
return container.height - Math.max(deck.minHeight, box.minHeight);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return document.getElementById("appcontent").boxObject.height;
|
||||||
|
},
|
||||||
|
|
||||||
|
get scripts() this.isComposeWindow() ? ["compose/compose.js"] : [
|
||||||
|
"addressbook.js",
|
||||||
|
"mail.js",
|
||||||
|
],
|
||||||
|
|
||||||
|
// to allow Vim to :set ft=mail automatically
|
||||||
|
tempFile: "mutt-ator-mail",
|
||||||
|
|
||||||
|
init: function () {
|
||||||
|
// don't wait too long when selecting new messages
|
||||||
|
// GetThreadTree()._selectDelay = 300; // TODO: make configurable
|
||||||
|
|
||||||
|
commands.add(["pref[erences]", "prefs"],
|
||||||
|
"Show " + config.hostApplication + " preferences",
|
||||||
|
function () { window.openOptionsDialog(); },
|
||||||
|
{ argCount: "0" });
|
||||||
|
|
||||||
|
// FIXME: comment obviously incorrect
|
||||||
|
// 0: never automatically edit externally
|
||||||
|
// 1: automatically edit externally when message window is shown the first time
|
||||||
|
// 2: automatically edit externally, once the message text gets focus (not working currently)
|
||||||
|
options.add(["autoexternal", "ae"],
|
||||||
|
"Edit message with external editor by default",
|
||||||
|
"boolean", false);
|
||||||
|
|
||||||
|
options.add(["online"],
|
||||||
|
"Set the 'work offline' option",
|
||||||
|
"boolean", true,
|
||||||
|
{
|
||||||
|
setter: function (value) {
|
||||||
|
if (MailOfflineMgr.isOnline() != value)
|
||||||
|
MailOfflineMgr.toggleOfflineStatus();
|
||||||
|
return value;
|
||||||
|
},
|
||||||
|
getter: function () MailOfflineMgr.isOnline()
|
||||||
|
});
|
||||||
|
|
||||||
|
//}}}
|
||||||
|
}
|
||||||
|
}; //}}}
|
||||||
|
|
||||||
// vim: set fdm=marker sw=4 ts=4 et:
|
// vim: set fdm=marker sw=4 ts=4 et:
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -221,18 +221,6 @@ const config = { //{{{
|
|||||||
context.completions = displayPanes; // FIXME: useful description etc
|
context.completions = displayPanes; // FIXME: useful description etc
|
||||||
};
|
};
|
||||||
|
|
||||||
// load Xulmus specific modules
|
|
||||||
liberator.loadModule("browser", Browser);
|
|
||||||
liberator.loadModule("finder", Finder);
|
|
||||||
liberator.loadModule("bookmarks", Bookmarks);
|
|
||||||
liberator.loadModule("history", History);
|
|
||||||
liberator.loadModule("tabs", Tabs);
|
|
||||||
liberator.loadModule("marks", Marks);
|
|
||||||
liberator.loadModule("quickmarks", QuickMarks);
|
|
||||||
liberator.loadModule("hints", Hints);
|
|
||||||
liberator.loadModule("player", Player);
|
|
||||||
liberator.loadModule("library", Library);
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////// STYLES //////////////////////////////////////////////////
|
////////////////////// STYLES //////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
@@ -251,10 +239,6 @@ const config = { //{{{
|
|||||||
delete img;
|
delete img;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// COMMANDS ////////////////////////////////////////////////
|
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|||||||
@@ -4,72 +4,55 @@
|
|||||||
// given in the LICENSE.txt file included with this file.
|
// given in the LICENSE.txt file included with this file.
|
||||||
|
|
||||||
|
|
||||||
function Library() { //{{{
|
const Library = Module("library", {
|
||||||
|
init: function () {
|
||||||
|
this.MAIN_LIBRARY = LibraryUtils.mainLibrary;
|
||||||
|
},
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
_toJSArray: function (enum) ArrayConverter.JSArray(enum),
|
||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
|
||||||
|
|
||||||
const MAIN_LIBRARY = LibraryUtils.mainLibrary;
|
|
||||||
|
|
||||||
function toJSArray(enum) ArrayConverter.JSArray(enum)
|
|
||||||
|
|
||||||
function getArtistsArray() {
|
|
||||||
return toJSArray(MAIN_LIBRARY.getDistinctValuesForProperty(SBProperties.artistName));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the artist names before hand.
|
|
||||||
let artists = getArtistsArray();
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
|
||||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
|
||||||
|
|
||||||
// TODO: return some actually useful objects. ;-)
|
// TODO: return some actually useful objects. ;-)
|
||||||
return {
|
/**
|
||||||
|
* Returns an array of all the artist names in the main library.
|
||||||
|
*
|
||||||
|
* @returns {string[]}
|
||||||
|
*/
|
||||||
|
getArtists: function getArtists() this._toJSArray(this.MAIN_LIBRARY.getDistinctValuesForProperty(SBProperties.artistName)),
|
||||||
|
|
||||||
/**
|
// FIXME: ken do we really want to remove duplicates? If so, why not tracks too? --djk
|
||||||
* Returns an array of all the artist names in the main library.
|
/**
|
||||||
*
|
* Returns an array of all the album names for <b>artist</b> in the
|
||||||
* @returns {string[]}
|
* main library.
|
||||||
*/
|
*
|
||||||
getArtists: function getArtists() artists,
|
* @param {param} artist The artist name.
|
||||||
|
* @returns {string[]}
|
||||||
|
*/
|
||||||
|
getAlbums: function getAlbums(artist) {
|
||||||
|
let albums = this._toJSArray(this.MAIN_LIBRARY.getItemsByProperty(SBProperties.artistName, artist))
|
||||||
|
.map(function (track) track.getProperty(SBProperties.albumName));
|
||||||
|
return util.Array.uniq(albums);
|
||||||
|
},
|
||||||
|
|
||||||
// FIXME: ken do we really want to remove duplicates? If so, why not tracks too? --djk
|
/**
|
||||||
/**
|
* Returns an array of all the track names for <b>artist</b> and
|
||||||
* Returns an array of all the album names for <b>artist</b> in the
|
* <b>album</b> in the main library.
|
||||||
* main library.
|
*
|
||||||
*
|
* @param {param} artist The artist name.
|
||||||
* @param {param} artist The artist name.
|
* @param {param} album The album name.
|
||||||
* @returns {string[]}
|
* @returns {string[]}
|
||||||
*/
|
*/
|
||||||
getAlbums: function getAlbums(artist) {
|
getTracks: function getTracks(artist, album) {
|
||||||
let albums = toJSArray(MAIN_LIBRARY.getItemsByProperty(SBProperties.artistName, artist))
|
const properties = Cc["@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"]
|
||||||
.map(function (track) track.getProperty(SBProperties.albumName));
|
.createInstance(Ci.sbIMutablePropertyArray);
|
||||||
return util.Array.uniq(albums);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
properties.appendProperty(SBProperties.artistName, artist);
|
||||||
* Returns an array of all the track names for <b>artist</b> and
|
properties.appendProperty(SBProperties.albumName, album);
|
||||||
* <b>album</b> in the main library.
|
|
||||||
*
|
|
||||||
* @param {param} artist The artist name.
|
|
||||||
* @param {param} album The album name.
|
|
||||||
* @returns {string[]}
|
|
||||||
*/
|
|
||||||
getTracks: function getTracks(artist, album) {
|
|
||||||
const properties = Cc["@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"]
|
|
||||||
.createInstance(Ci.sbIMutablePropertyArray);
|
|
||||||
|
|
||||||
properties.appendProperty(SBProperties.artistName, artist);
|
return this._toJSArray(this.MAIN_LIBRARY.getItemsByProperties(properties))
|
||||||
properties.appendProperty(SBProperties.albumName, album);
|
.map(function (track) track.getProperty(SBProperties.trackName));
|
||||||
|
}
|
||||||
return toJSArray(MAIN_LIBRARY.getItemsByProperties(properties))
|
}, {
|
||||||
.map(function (track) track.getProperty(SBProperties.trackName));
|
}, {
|
||||||
}
|
});
|
||||||
|
|
||||||
};
|
|
||||||
//}}}
|
|
||||||
} //}}}
|
|
||||||
|
|
||||||
// vim: set fdm=marker sw=4 ts=4 et:
|
// vim: set fdm=marker sw=4 ts=4 et:
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user