mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 10:07:59 +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
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
|
||||
function Addressbook() { //{{{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
const abManager = Cc["@mozilla.org/abmanager;1"].getService(Ci.nsIAbManager);
|
||||
const rdf = Cc["@mozilla.org/rdf/rdf-service;1"].getService(Ci.nsIRDFService);
|
||||
const Addressbook = Module("addressbook", {
|
||||
init: function () {
|
||||
},
|
||||
|
||||
// TODO: add option for a format specifier, like:
|
||||
// :set displayname=%l, %f
|
||||
function generateDisplayName(firstName, lastName) {
|
||||
generateDisplayName: function (firstName, lastName) {
|
||||
if (firstName && lastName)
|
||||
return lastName + ", " + firstName;
|
||||
else if (firstName)
|
||||
@@ -22,150 +18,134 @@ function Addressbook() { //{{{
|
||||
return lastName;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
},
|
||||
|
||||
function getDirectoryFromURI(uri) services.get("rdf").GetResource(uri).QueryInterface(Ci.nsIAbDirectory)
|
||||
getDirectoryFromURI: function (uri) services.get("rdf").GetResource(uri).QueryInterface(Ci.nsIAbDirectory),
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////}}}
|
||||
////////////////////// OPTIONS /////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
add: function (address, firstName, lastName, displayName) {
|
||||
const personalAddressbookURI = "moz-abmdbdirectory://abook.mab";
|
||||
let directory = this.getDirectoryFromURI(personalAddressbookURI);
|
||||
let card = Cc["@mozilla.org/addressbook/cardproperty;1"].createInstance(Ci.nsIAbCard);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////}}}
|
||||
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
if (!address || !directory || !card)
|
||||
return false;
|
||||
|
||||
var myModes = config.mailModes;
|
||||
card.primaryEmail = address;
|
||||
card.firstName = firstName;
|
||||
card.lastName = lastName;
|
||||
card.displayName = displayName;
|
||||
|
||||
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;
|
||||
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 = 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:
|
||||
|
||||
@@ -3,214 +3,185 @@
|
||||
// This work is licensed for reuse under an MIT license. Details are
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
|
||||
const config = (function () { //{{{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
const config = { //{{{
|
||||
/*** required options, no checks done if they really exist, so be careful ***/
|
||||
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";
|
||||
var host = "Thunderbird";
|
||||
var tabmail;
|
||||
get mainWindowId() this.isComposeWindow ? "msgcomposeWindow" : "messengerWindow",
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////}}}
|
||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
/*** optional options, there are checked for existence and a fallback provided ***/
|
||||
features: ["hints", "mail", "marks", "addressbook", "tabs"],
|
||||
defaults: {
|
||||
guioptions: "frb",
|
||||
showtabline: 1,
|
||||
titlestring: "Muttator"
|
||||
},
|
||||
|
||||
return {
|
||||
/*** required options, no checks done if they really exist, so be careful ***/
|
||||
name: name,
|
||||
hostApplication: host, // 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
|
||||
get mainWindowId() this.isComposeWindow ? "msgcomposeWindow" : "messengerWindow",
|
||||
guioptions: {
|
||||
m: ["MenuBar", ["mail-toolbar-menubar2"]],
|
||||
T: ["Toolbar" , ["mail-bar2"]],
|
||||
f: ["Folder list", ["folderPaneBox", "folderpane_splitter"]],
|
||||
F: ["Folder list header", ["folderPaneHeader"]]
|
||||
},
|
||||
|
||||
/*** optional options, there are checked for existence and a fallback provided ***/
|
||||
features: ["hints", "mail", "marks", "addressbook", "tabs"],
|
||||
defaults: {
|
||||
guioptions: "frb",
|
||||
showtabline: 1,
|
||||
titlestring: name
|
||||
},
|
||||
get isComposeWindow() window.wintype == "msgcompose",
|
||||
get browserModes() [modes.MESSAGE],
|
||||
get mailModes() [modes.NORMAL],
|
||||
// focusContent() focuses this widget
|
||||
get mainWidget() this.isComposeWindow ? document.getElementById("content-frame") : GetThreadTree(),
|
||||
get visualbellWindow() document.getElementById(this.mainWindowId),
|
||||
styleableChrome: ["chrome://messenger/content/messenger.xul",
|
||||
"chrome://messenger/content/messengercompose/messengercompose.xul"],
|
||||
|
||||
guioptions: {
|
||||
m: ["MenuBar", ["mail-toolbar-menubar2"]],
|
||||
T: ["Toolbar" , ["mail-bar2"]],
|
||||
f: ["Folder list", ["folderPaneBox", "folderpane_splitter"]],
|
||||
F: ["Folder list header", ["folderPaneHeader"]]
|
||||
},
|
||||
autocommands: [["DOMLoad", "Triggered when a page's DOM content has fully loaded"],
|
||||
["FolderLoad", "Triggered after switching folders in Thunderbird"],
|
||||
["PageLoadPre", "Triggered after a page load is initiated"],
|
||||
["PageLoad", "Triggered when a page gets (re)loaded/opened"],
|
||||
["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",
|
||||
get browserModes() [modes.MESSAGE],
|
||||
get mailModes() [modes.NORMAL],
|
||||
// focusContent() focuses this widget
|
||||
get mainWidget() this.isComposeWindow ? document.getElementById("content-frame") : GetThreadTree(),
|
||||
get visualbellWindow() document.getElementById(this.mainWindowId),
|
||||
styleableChrome: ["chrome://messenger/content/messenger.xul",
|
||||
"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()
|
||||
});
|
||||
|
||||
//}}}
|
||||
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 () {
|
||||
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:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -221,18 +221,6 @@ const config = { //{{{
|
||||
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 //////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
@@ -251,10 +239,6 @@ const config = { //{{{
|
||||
delete img;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////}}}
|
||||
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
@@ -4,72 +4,55 @@
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
|
||||
|
||||
function Library() { //{{{
|
||||
const Library = Module("library", {
|
||||
init: function () {
|
||||
this.MAIN_LIBRARY = LibraryUtils.mainLibrary;
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// 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 //////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
_toJSArray: function (enum) ArrayConverter.JSArray(enum),
|
||||
|
||||
// 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)),
|
||||
|
||||
/**
|
||||
* Returns an array of all the artist names in the main library.
|
||||
*
|
||||
* @returns {string[]}
|
||||
*/
|
||||
getArtists: function getArtists() artists,
|
||||
// FIXME: ken do we really want to remove duplicates? If so, why not tracks too? --djk
|
||||
/**
|
||||
* Returns an array of all the album names for <b>artist</b> in the
|
||||
* main library.
|
||||
*
|
||||
* @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 album names for <b>artist</b> in the
|
||||
* main library.
|
||||
*
|
||||
* @param {param} artist The artist name.
|
||||
* @returns {string[]}
|
||||
*/
|
||||
getAlbums: function getAlbums(artist) {
|
||||
let albums = toJSArray(MAIN_LIBRARY.getItemsByProperty(SBProperties.artistName, artist))
|
||||
.map(function (track) track.getProperty(SBProperties.albumName));
|
||||
return util.Array.uniq(albums);
|
||||
},
|
||||
/**
|
||||
* Returns an array of all the track names for <b>artist</b> and
|
||||
* <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);
|
||||
|
||||
/**
|
||||
* Returns an array of all the track names for <b>artist</b> and
|
||||
* <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);
|
||||
properties.appendProperty(SBProperties.albumName, album);
|
||||
|
||||
properties.appendProperty(SBProperties.artistName, artist);
|
||||
properties.appendProperty(SBProperties.albumName, album);
|
||||
|
||||
return toJSArray(MAIN_LIBRARY.getItemsByProperties(properties))
|
||||
.map(function (track) track.getProperty(SBProperties.trackName));
|
||||
}
|
||||
|
||||
};
|
||||
//}}}
|
||||
} //}}}
|
||||
return this._toJSArray(this.MAIN_LIBRARY.getItemsByProperties(properties))
|
||||
.map(function (track) track.getProperty(SBProperties.trackName));
|
||||
}
|
||||
}, {
|
||||
}, {
|
||||
});
|
||||
|
||||
// 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