fix for #64462. play OS specified sound when new mail arrives.
r=pavlov, sr=bienvenu. right now, this only works on windows. mac is next. for linux (and the other platforms), we currently beep. if there isn't an OS specified sound, we'll play the pre-packaged sound that mailnews will eventually ship with.
This commit is contained in:
Родитель
49db831c73
Коммит
9751d70f08
|
@ -130,45 +130,11 @@ nsresult nsStatusBarBiffManager::PerformStatusBarBiff(PRUint32 newBiffFlag)
|
|||
if (NS_SUCCEEDED(rv) && playSoundOnBiff) {
|
||||
nsCOMPtr<nsISound> sound = do_CreateInstance("@mozilla.org/sound;1");
|
||||
if (sound) {
|
||||
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 = NS_NewFileURI(getter_AddRefs(uri), file);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
else {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((NS_FAILED(rv) || playDefaultSound) && nsCRT::strlen(mDefaultSoundURL.get())) {
|
||||
rv = NS_NewURI(getter_AddRefs(uri), mDefaultSoundURL.get());
|
||||
}
|
||||
}
|
||||
|
||||
nsXPIDLCString soundURLSpec;
|
||||
if (uri)
|
||||
rv = uri->GetSpec(getter_Copies(soundURLSpec));
|
||||
else
|
||||
rv = NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIURL> soundURL(do_QueryInterface(uri));
|
||||
if (NS_SUCCEEDED(rv) && soundURL && nsCRT::strlen(soundURLSpec.get())) {
|
||||
sound->Play(soundURL);
|
||||
}
|
||||
else {
|
||||
sound->Beep();
|
||||
}
|
||||
rv = sound->PlaySystemSound("Mailbeep");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWindowMediator> windowMediator =
|
||||
do_GetService(kWindowMediatorCID, &rv);
|
||||
|
|
|
@ -29,5 +29,9 @@ interface nsIURL;
|
|||
interface nsISound : nsISupports
|
||||
{
|
||||
void play(in nsIURL aURL);
|
||||
/**
|
||||
* for playing system sounds
|
||||
*/
|
||||
void playSystemSound(in string soundAlias);
|
||||
void beep();
|
||||
};
|
||||
|
|
|
@ -110,3 +110,8 @@ NS_METHOD nsSound::Play(nsIURL *aURL)
|
|||
*/
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSound::PlaySystemSound(const char *aSoundAlias)
|
||||
{
|
||||
return Beep();
|
||||
}
|
||||
|
|
|
@ -243,3 +243,8 @@ NS_METHOD nsSound::Play(nsIURL *aURL)
|
|||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSound::PlaySystemSound(const char *aSoundAlias)
|
||||
{
|
||||
return Beep();
|
||||
}
|
||||
|
|
|
@ -180,3 +180,8 @@ PRBool nsSound::HaveQuickTime()
|
|||
OSErr err = Gestalt (gestaltQuickTime, &gestResult);
|
||||
return (err == noErr) && ((long)EnterMovies != kUnresolvedCFragSymbolAddress);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSound::PlaySystemSound(const char *aSoundAlias)
|
||||
{
|
||||
return Beep();
|
||||
}
|
||||
|
|
|
@ -109,3 +109,8 @@ NS_METHOD nsSound::Play(nsIURL *aURL)
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSound::PlaySystemSound(const char *aSoundAlias)
|
||||
{
|
||||
return Beep();
|
||||
}
|
||||
|
||||
|
|
|
@ -114,3 +114,7 @@ NS_IMETHODIMP nsSound::OnStreamComplete(nsIStreamLoader *aLoader,
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSound::PlaySystemSound(const char *aSoundAlias)
|
||||
{
|
||||
return Beep();
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ void nsSound::PurgeLastSound() {
|
|||
}
|
||||
}
|
||||
|
||||
NS_METHOD nsSound::Beep()
|
||||
NS_IMETHODIMP nsSound::Beep()
|
||||
{
|
||||
::MessageBeep(0);
|
||||
|
||||
|
@ -140,7 +140,7 @@ NS_IMETHODIMP nsSound::OnStreamComplete(nsIStreamLoader *aLoader,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsSound::Play(nsIURL *aURL)
|
||||
NS_IMETHODIMP nsSound::Play(nsIURL *aURL)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
@ -156,3 +156,13 @@ NS_METHOD nsSound::Play(nsIURL *aURL)
|
|||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsSound::PlaySystemSound(const char *aSoundAlias)
|
||||
{
|
||||
PurgeLastSound();
|
||||
|
||||
::PlaySound(aSoundAlias, nsnull, SND_ALIAS | SND_ASYNC);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -85,3 +85,8 @@ NS_METHOD nsSound::Play(nsIURL *aURL)
|
|||
#endif /* DEBUG_faulkner */
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSound::PlaySystemSound(const char *aSoundAlias)
|
||||
{
|
||||
return Beep();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче