зеркало из https://github.com/mozilla/pjs.git
fix for #36025. play sound when new mail arrives. thanks to
rcassin@supernova.org for the front end work. all the prefs work, but we only have UI for enabling / disabling the sound. sr=bienvenu
This commit is contained in:
Родитель
54be2d9937
Коммит
99dcbaa064
|
@ -16,3 +16,4 @@ function setHomePageToDefaultPage(folderFieldId)
|
|||
var url = prefs.getDefaultLocalizedUnicharPref("mailnews.start_page.url");
|
||||
homePageField.value = url;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,29 @@
|
|||
<?xml-stylesheet href="chrome://messenger/skin/pref-mailnews.css" type="text/css"?>
|
||||
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
|
||||
|
||||
<!--
|
||||
The contents of this file are subject to the Netscape Public
|
||||
License Version 1.1 (the "License"); you may not use this file
|
||||
except in compliance with the License. You may obtain a copy of
|
||||
the License at http://www.mozilla.org/NPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS
|
||||
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
implied. See the License for the specific language governing
|
||||
rights and limitations under the License.
|
||||
|
||||
The Original Code is Mozilla Communicator client code, released
|
||||
March 31, 1998.
|
||||
|
||||
The Initial Developer of the Original Code is Netscape
|
||||
Communications Corporation. Portions created by Netscape are
|
||||
Copyright (C) 1998-2001 Netscape Communications Corporation. All
|
||||
Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
rcassin@supernova.org
|
||||
-->
|
||||
|
||||
<!DOCTYPE window SYSTEM "chrome://messenger/locale/pref-mailnews.dtd">
|
||||
|
||||
<window xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
|
@ -14,7 +37,8 @@
|
|||
<script language="javascript">
|
||||
<![CDATA[
|
||||
var _elementIDs = ["mailPaneConfig", "mailnewsConfirmMoveFoldersToTrash",
|
||||
"mailnewsStartPageEnabled", "mailnewsStartPageUrl"];
|
||||
"mailnewsStartPageEnabled", "mailnewsStartPageUrl",
|
||||
"newMailNotification" ];
|
||||
]]>
|
||||
</script>
|
||||
<script language="javascript" src="chrome://global/content/strres.js"/>
|
||||
|
@ -62,5 +86,15 @@
|
|||
</box>
|
||||
|
||||
</titledbox>
|
||||
|
||||
|
||||
<!-- Sound notification for new mail -->
|
||||
<titledbox orient="vertical">
|
||||
<title><text value="&newMessage.label;"/></title>
|
||||
|
||||
<checkbox allowevents="true" id="newMailNotification" value="&playSound.label;"
|
||||
pref="true" preftype="bool" prefstring="mail.biff.play_sound"
|
||||
prefattribute="checked" accesskey="&playSound.accesskey;" />
|
||||
|
||||
</titledbox>
|
||||
|
||||
</window>
|
||||
|
|
|
@ -24,8 +24,13 @@ Rights Reserved.
|
|||
<!ENTITY windowSettings.label "General Settings">
|
||||
<!ENTITY selectWindowLayout.label "Select the window layout you prefer for Mail:">
|
||||
<!ENTITY chooseExp.label "Note: For this setting to take effect, you will need to exit and then restart Mail.">
|
||||
<!ENTITY playSound.label "Play a sound when new messages arrive">
|
||||
<!ENTITY newMessage.label "When a new message arrives">
|
||||
<!ENTITY playSound.label "Play a sound">
|
||||
<!ENTITY playSound.accesskey "p">
|
||||
<!ENTITY soundFile.label "Sound file:">
|
||||
<!ENTITY defaultSound.label "Play default sound">
|
||||
<!ENTITY browse.label "Browse">
|
||||
<!ENTITY browse.accesskey "b">
|
||||
<!ENTITY confirmMove.label "Confirm when moving folders to the Trash">
|
||||
<!ENTITY confirmMove.accesskey "c">
|
||||
<!ENTITY useMessenger.label "Use Mail from MAPI-based applications">
|
||||
|
|
Двоичный файл не отображается.
|
@ -35,6 +35,10 @@
|
|||
#include "nsMsgFolderDataSource.h"
|
||||
#include "MailNewsTypes.h"
|
||||
#include "nsIMsgFolder.h" // TO include biffState enum. Change to bool later...
|
||||
#include "nsISound.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIURL.h"
|
||||
|
||||
static NS_DEFINE_CID(kMsgAccountManagerCID, NS_MSGACCOUNTMANAGER_CID);
|
||||
static NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID);
|
||||
|
@ -79,11 +83,61 @@ nsresult nsStatusBarBiffManager::Shutdown()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
#define PREF_PLAY_SOUND_ON_NEW_MAIL "mail.biff.play_sound"
|
||||
#define PREF_PLAY_DEFAULT_SOUND "mail.biff.use_default_sound"
|
||||
#define PREF_USER_SPECIFIED_SOUND_FILE "mail.biff.sound_file"
|
||||
#define DEFAULT_NEW_MAIL_SOUND "chrome://messenger/content/newmail.wav"
|
||||
|
||||
nsresult nsStatusBarBiffManager::PerformStatusBarBiff(PRUint32 newBiffFlag)
|
||||
{
|
||||
|
||||
// See nsMsgStatusFeedback
|
||||
nsresult rv;
|
||||
|
||||
// if we got new mail, attempt to play a sound.
|
||||
// if we fail along the way, don't return.
|
||||
// we still need to update the UI.
|
||||
if (newBiffFlag == nsIMsgFolder::nsMsgBiffState_NewMail) {
|
||||
nsCOMPtr<nsIPref> pref = do_GetService(NS_PREF_CONTRACTID);
|
||||
if (pref) {
|
||||
PRBool playSoundOnBiff = PR_FALSE;
|
||||
rv = pref->GetBoolPref(PREF_PLAY_SOUND_ON_NEW_MAIL, &playSoundOnBiff);
|
||||
if (NS_SUCCEEDED(rv) && playSoundOnBiff) {
|
||||
nsCOMPtr<nsISound> sound = do_CreateInstance("@mozilla.org/sound;1");
|
||||
if (sound) {
|
||||
nsCOMPtr<nsIFileURL> soundURL = do_CreateInstance("@mozilla.org/network/standard-url;1");
|
||||
if (soundURL) {
|
||||
PRBool playDefaultSound = PR_TRUE;
|
||||
rv = pref->GetBoolPref(PREF_PLAY_DEFAULT_SOUND, &playDefaultSound);
|
||||
if (NS_SUCCEEDED(rv) && !playDefaultSound) {
|
||||
nsCOMPtr<nsILocalFile> soundFile;
|
||||
rv = pref->GetFileXPref(PREF_USER_SPECIFIED_SOUND_FILE, getter_AddRefs(soundFile));
|
||||
if (NS_SUCCEEDED(rv) && soundFile) {
|
||||
nsCOMPtr <nsIFile> file = do_QueryInterface(soundFile);
|
||||
if (file) {
|
||||
rv = soundURL->SetFile(file);
|
||||
}
|
||||
else {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv) || playDefaultSound) {
|
||||
rv = soundURL->SetSpec(DEFAULT_NEW_MAIL_SOUND);
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv) && soundURL) {
|
||||
sound->Play(soundURL);
|
||||
}
|
||||
else {
|
||||
sound->Beep();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_WITH_SERVICE(nsIWindowMediator, windowMediator, kWindowMediatorCID, &rv);
|
||||
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
|
||||
|
||||
|
|
|
@ -156,6 +156,7 @@ messenger.jar:
|
|||
content/messenger/popTest.xul (base/resources/content/popTest.xul)
|
||||
content/messenger/pref-advanced_overlay.xul (base/prefs/resources/content/pref-advanced_overlay.xul)
|
||||
content/messenger/pref-appearance_overlay.xul (base/prefs/resources/content/pref-appearance_overlay.xul)
|
||||
content/messenger/newmail.wav (base/resources/content/newmail.wav)
|
||||
|
||||
en-US.jar:
|
||||
locale/en-US/messenger/contents.rdf (base/resources/locale/en-US/contents.rdf)
|
||||
|
|
|
@ -141,7 +141,6 @@ pref("mail.attach_vcard", false);
|
|||
pref("mail.html_compose", true);
|
||||
pref("mail.compose.other.header", "");
|
||||
pref("mail.htmldomains", "netscape.com,mcom.com");
|
||||
pref("mail.play_sound", true);
|
||||
pref("mail.send_html", true);
|
||||
pref("mail.directory_names.first_first", true);
|
||||
pref("mail.attach_address_card", false);
|
||||
|
@ -434,3 +433,8 @@ pref("news.cancel.confirm",true);
|
|||
pref("news.cancel.alert_on_success",true);
|
||||
pref("mail.SpellCheckBeforeSend",false);
|
||||
pref("mail.enable_autocomplete",true);
|
||||
|
||||
pref("mail.biff.play_sound",true);
|
||||
pref("mail.biff.use_default_sound",true);
|
||||
pref("mail.biff.sound_file","");
|
||||
|
||||
|
|
|
@ -141,7 +141,6 @@ pref("mail.attach_vcard", false);
|
|||
pref("mail.html_compose", true);
|
||||
pref("mail.compose.other.header", "");
|
||||
pref("mail.htmldomains", "netscape.com,mcom.com");
|
||||
pref("mail.play_sound", true);
|
||||
pref("mail.send_html", true);
|
||||
pref("mail.directory_names.first_first", true);
|
||||
pref("mail.attach_address_card", false);
|
||||
|
@ -434,3 +433,8 @@ pref("news.cancel.confirm",true);
|
|||
pref("news.cancel.alert_on_success",true);
|
||||
pref("mail.SpellCheckBeforeSend",false);
|
||||
pref("mail.enable_autocomplete",true);
|
||||
|
||||
pref("mail.biff.play_sound",true);
|
||||
pref("mail.biff.use_default_sound",true);
|
||||
pref("mail.biff.sound_file","");
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче