2006-05-17 02:23:11 +00:00
|
|
|
function Startup()
|
|
|
|
{
|
|
|
|
PlaySoundCheck();
|
2006-05-17 02:23:12 +00:00
|
|
|
|
2006-05-17 02:23:14 +00:00
|
|
|
// if we don't have the alert service, hide the pref UI for using alerts to notify on new mail
|
2006-05-17 02:23:12 +00:00
|
|
|
// see bug #158711
|
2006-05-17 02:23:14 +00:00
|
|
|
var newMailNotificationAlertUI = document.getElementById("newMailNotificationAlert");
|
|
|
|
newMailNotificationAlertUI.hidden = !("@mozilla.org/alerts-service;1" in Components.classes);
|
2006-05-17 02:23:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function PlaySoundCheck()
|
|
|
|
{
|
|
|
|
var playSound = document.getElementById("newMailNotification").checked;
|
|
|
|
var playSoundType = document.getElementById("newMailNotificationType");
|
|
|
|
playSoundType.disabled = !playSound;
|
|
|
|
|
|
|
|
var disableCustomUI = !(playSound && playSoundType.value == 1);
|
|
|
|
var mailnewsSoundFileUrl = document.getElementById("mailnewsSoundFileUrl");
|
|
|
|
|
|
|
|
mailnewsSoundFileUrl.disabled = disableCustomUI
|
|
|
|
document.getElementById("preview").disabled = disableCustomUI || (mailnewsSoundFileUrl.value == "");
|
|
|
|
document.getElementById("browse").disabled = disableCustomUI;
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsIFilePicker = Components.interfaces.nsIFilePicker;
|
|
|
|
|
|
|
|
function Browse()
|
|
|
|
{
|
|
|
|
var fp = Components.classes["@mozilla.org/filepicker;1"]
|
|
|
|
.createInstance(nsIFilePicker);
|
|
|
|
|
|
|
|
// XXX todo, persist the last sound directory and pass it in
|
|
|
|
// XXX todo filter by .wav
|
|
|
|
fp.init(window, document.getElementById("browse").getAttribute("filepickertitle"), nsIFilePicker.modeOpen);
|
|
|
|
fp.appendFilters(nsIFilePicker.filterAll);
|
|
|
|
|
|
|
|
var ret = fp.show();
|
|
|
|
if (ret == nsIFilePicker.returnOK) {
|
|
|
|
var mailnewsSoundFileUrl = document.getElementById("mailnewsSoundFileUrl");
|
2006-05-17 02:24:51 +00:00
|
|
|
// convert the nsILocalFile into a nsIFile url
|
|
|
|
mailnewsSoundFileUrl.value = fp.fileURL.spec;
|
2006-05-17 02:23:11 +00:00
|
|
|
}
|
|
|
|
|
2006-05-17 02:24:51 +00:00
|
|
|
document.getElementById("preview").disabled = (document.getElementById("mailnewsSoundFileUrl").value == "");
|
2006-05-17 02:23:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var gSound = null;
|
|
|
|
|
|
|
|
function PreviewSound()
|
|
|
|
{
|
|
|
|
var soundURL = document.getElementById("mailnewsSoundFileUrl").value;
|
|
|
|
|
|
|
|
if (!gSound)
|
|
|
|
gSound = Components.classes["@mozilla.org/sound;1"].createInstance(Components.interfaces.nsISound);
|
|
|
|
|
|
|
|
if (soundURL.indexOf("file://") == -1) {
|
|
|
|
// XXX todo see if we can create a nsIURL from the native file path
|
|
|
|
// otherwise, play a system sound
|
|
|
|
gSound.playSystemSound(soundURL);
|
|
|
|
}
|
|
|
|
else {
|
2006-05-17 02:24:42 +00:00
|
|
|
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIIOService);
|
|
|
|
var url = ioService.newURI(soundURL, null, null);
|
2006-05-17 02:23:11 +00:00
|
|
|
gSound.play(url)
|
|
|
|
}
|
|
|
|
}
|