зеркало из https://github.com/mozilla/gecko-dev.git
Bug 207102 Sound preview doesn't work if its path contains non-ASCII string r=amardare+jshin, sr=roc
This commit is contained in:
Родитель
fc941fb73d
Коммит
be3db1997d
|
@ -81,7 +81,7 @@ nsStatusBarBiffManager::~nsStatusBarBiffManager()
|
|||
#define PREF_NEW_MAIL_SOUND_TYPE "mail.biff.play_sound.type"
|
||||
#define SYSTEM_SOUND_TYPE 0
|
||||
#define CUSTOM_SOUND_TYPE 1
|
||||
#define DEFAULT_SYSTEM_SOUND "_moz_mailbeep"
|
||||
#define DEFAULT_SYSTEM_SOUND NS_LITERAL_STRING("_moz_mailbeep")
|
||||
|
||||
nsresult nsStatusBarBiffManager::Init()
|
||||
{
|
||||
|
@ -150,7 +150,8 @@ nsresult nsStatusBarBiffManager::PlayBiffSound()
|
|||
else {
|
||||
// todo, see if we can create a nsIFile using the string as a native path.
|
||||
// if that fails, try playing a system sound
|
||||
rv = mSound->PlaySystemSound(soundURLSpec.get());
|
||||
NS_ConvertUTF8toUTF16 utf16SoundURLSpec(soundURLSpec);
|
||||
rv = mSound->PlaySystemSound(utf16SoundURLSpec);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
customSoundPlayed = PR_TRUE;
|
||||
}
|
||||
|
|
|
@ -41,14 +41,14 @@
|
|||
|
||||
interface nsIURL;
|
||||
|
||||
[scriptable, uuid(B148EED1-236D-11d3-B35C-00A0CC3C1CDE)]
|
||||
[scriptable, uuid(B01ADAD7-D937-4738-8508-3BD5946BF9C8)]
|
||||
interface nsISound : nsISupports
|
||||
{
|
||||
void play(in nsIURL aURL);
|
||||
/**
|
||||
* for playing system sounds
|
||||
*/
|
||||
void playSystemSound(in string soundAlias);
|
||||
void playSystemSound(in AString soundAlias);
|
||||
void beep();
|
||||
|
||||
/**
|
||||
|
|
|
@ -107,7 +107,7 @@ NS_METHOD nsSound::Play(nsIURL *aURL)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSound::PlaySystemSound(const char *aSoundAlias)
|
||||
NS_IMETHODIMP nsSound::PlaySystemSound(const nsAString &aSoundAlias)
|
||||
{
|
||||
return Beep();
|
||||
}
|
||||
|
|
|
@ -290,10 +290,9 @@ NS_METHOD nsSound::Play(nsIURL *aURL)
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSound::PlaySystemSound(const char *aSoundAlias)
|
||||
NS_IMETHODIMP nsSound::PlaySystemSound(const nsAString &aSoundAlias)
|
||||
{
|
||||
if (!aSoundAlias) return NS_ERROR_FAILURE;
|
||||
if (strcmp(aSoundAlias, "_moz_mailbeep") == 0)
|
||||
if (aSoundAlias.EqualsLiteral("_moz_mailbeep"))
|
||||
{
|
||||
return Beep();
|
||||
}
|
||||
|
@ -302,8 +301,8 @@ NS_IMETHODIMP nsSound::PlaySystemSound(const char *aSoundAlias)
|
|||
|
||||
// create a nsILocalFile and then a nsIFileURL from that
|
||||
nsCOMPtr <nsILocalFile> soundFile;
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(aSoundAlias), PR_TRUE,
|
||||
getter_AddRefs(soundFile));
|
||||
rv = NS_NewLocalFile(aSoundAlias, PR_TRUE,
|
||||
getter_AddRefs(soundFile));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = NS_NewFileURI(getter_AddRefs(fileURI), soundFile);
|
||||
|
|
|
@ -294,12 +294,9 @@ NS_METHOD nsSound::Play(nsIURL *aURL)
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSound::PlaySystemSound(const char *aSoundAlias)
|
||||
NS_IMETHODIMP nsSound::PlaySystemSound(const nsAString &aSoundAlias)
|
||||
{
|
||||
if (!aSoundAlias)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (strcmp(aSoundAlias, "_moz_mailbeep") == 0) {
|
||||
if (aSoundAlias.EqualsLiteral("_moz_mailbeep")) {
|
||||
return Beep();
|
||||
}
|
||||
|
||||
|
@ -308,8 +305,8 @@ NS_IMETHODIMP nsSound::PlaySystemSound(const char *aSoundAlias)
|
|||
|
||||
// create a nsILocalFile and then a nsIFileURL from that
|
||||
nsCOMPtr <nsILocalFile> soundFile;
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(aSoundAlias), PR_TRUE,
|
||||
getter_AddRefs(soundFile));
|
||||
rv = NS_NewLocalFile(aSoundAlias, PR_TRUE,
|
||||
getter_AddRefs(soundFile));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = NS_NewFileURI(getter_AddRefs(fileURI), soundFile);
|
||||
|
|
|
@ -229,7 +229,7 @@ nsSound::Init()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSound::PlaySystemSound(const char *aSoundName)
|
||||
nsSound::PlaySystemSound(const nsAString &aSoundName)
|
||||
{
|
||||
nsCOMPtr<nsISupports> requestSupports;
|
||||
|
||||
|
@ -241,7 +241,8 @@ nsSound::PlaySystemSound(const char *aSoundName)
|
|||
requestSupports = NS_STATIC_CAST(nsITimerCallback*, soundRequest);
|
||||
|
||||
Str255 soundResource;
|
||||
nsresult rv = GetSoundResourceName(aSoundName, soundResource);
|
||||
nsresult rv = GetSoundResourceName(NS_ConvertUTF16toUTF8(aSoundName).get(),
|
||||
soundResource);
|
||||
if (NS_FAILED(rv))
|
||||
return Beep();
|
||||
|
||||
|
|
|
@ -55,6 +55,8 @@
|
|||
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
|
||||
#include "nsNativeCharsetUtils.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsSound, nsISound, nsIStreamLoaderObserver)
|
||||
|
||||
static int gInitialized = 0;
|
||||
|
@ -218,15 +220,17 @@ NS_IMETHODIMP nsSound::Init()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSound::PlaySystemSound(const char *aSoundAlias)
|
||||
NS_IMETHODIMP nsSound::PlaySystemSound(const nsAString &aSoundAlias)
|
||||
{
|
||||
/* We don't have a default mail sound on OS/2, so just beep */
|
||||
/* Also just beep if MMPM isn't installed */
|
||||
if ((strcmp("_moz_mailbeep", aSoundAlias) == 0) || (!gMMPMInstalled)) {
|
||||
if (aSoundAlias.EqualsLiteral("_moz_mailbeep") || (!gMMPMInstalled)) {
|
||||
Beep();
|
||||
}
|
||||
else {
|
||||
HOBJECT hobject = WinQueryObject(aSoundAlias);
|
||||
nsCAutoString nativeSoundAlias;
|
||||
NS_CopyUnicodeToNative(aSoundAlias, nativeSoundAlias);
|
||||
HOBJECT hobject = WinQueryObject(nativeSoundAlias.get());
|
||||
if (hobject)
|
||||
WinSetObjectData(hobject, "OPEN=DEFAULT");
|
||||
else
|
||||
|
|
|
@ -106,24 +106,30 @@ printf( "\n\n\nnsSound::OnStreamComplete stringData=%s\n\n", stringData );
|
|||
|
||||
static void child_exit( void *data, int status ) { }
|
||||
|
||||
NS_IMETHODIMP nsSound::PlaySystemSound(const char *aSoundAlias)
|
||||
NS_IMETHODIMP nsSound::PlaySystemSound(const nsAString &aSoundAlias)
|
||||
{
|
||||
NS_ConvertUTF16toUTF8 utf8SoundAlias(aSoundAlias);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf( "\n\n\nnsSound::PlaySystemSound aSoundAlias=%s\n\n", aSoundAlias );
|
||||
printf( "\n\n\nnsSound::PlaySystemSound aSoundAlias=%s\n\n",
|
||||
utf8SoundAlias.get() );
|
||||
#endif
|
||||
|
||||
const char *soundfile;
|
||||
const char *soundfile;
|
||||
|
||||
if( !strcmp( "_moz_mailbeep", aSoundAlias ) )
|
||||
soundfile = "/usr/share/mozilla/gotmail.wav";
|
||||
else {
|
||||
if( !access( aSoundAlias, F_OK ) ) /* the aSoundAlias is the fullpath to the soundfile */
|
||||
soundfile = aSoundAlias;
|
||||
else soundfile = "/usr/share/mozilla/rest.wav";
|
||||
}
|
||||
if( utf8SoundAlias.Equals("_moz_mailbeep") )
|
||||
soundfile = "/usr/share/mozilla/gotmail.wav";
|
||||
else {
|
||||
/* the aSoundAlias is the fullpath to the soundfile */
|
||||
if( !access( utf8SoundAlias.get(), F_OK ) )
|
||||
soundfile = utf8SoundAlias.get();
|
||||
else
|
||||
soundfile = "/usr/share/mozilla/rest.wav";
|
||||
}
|
||||
|
||||
const char* argv[] = { "/opt/Mozilla/mozilla/wave", soundfile, NULL };
|
||||
PtSpawn( "/opt/Mozilla/mozilla/wave", ( const char ** ) argv, NULL, NULL, child_exit, NULL, NULL );
|
||||
const char* argv[] = { "/opt/Mozilla/mozilla/wave", soundfile, NULL };
|
||||
PtSpawn( "/opt/Mozilla/mozilla/wave", ( const char ** ) argv,
|
||||
NULL, NULL, child_exit, NULL, NULL );
|
||||
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -84,11 +84,9 @@ NS_METHOD nsSound::Play(nsIURL *aURL)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSound::PlaySystemSound(const char *aSoundAlias)
|
||||
NS_IMETHODIMP nsSound::PlaySystemSound(const nsAString &aSoundAlias)
|
||||
{
|
||||
if (!aSoundAlias)
|
||||
return NS_ERROR_FAILURE;
|
||||
if (strcmp(aSoundAlias, "_moz_mailbeep") == 0) {
|
||||
if (aSoundAlias.EqualsLiteral("_moz_mailbeep")) {
|
||||
QApplication::beep();
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -100,8 +98,8 @@ NS_IMETHODIMP nsSound::PlaySystemSound(const char *aSoundAlias)
|
|||
|
||||
// // create a nsILocalFile and then a nsIFileURL from that
|
||||
// nsCOMPtr <nsILocalFile> soundFile;
|
||||
// rv = NS_NewNativeLocalFile(nsDependentCString(aSoundAlias), PR_TRUE,
|
||||
// getter_AddRefs(soundFile));
|
||||
// rv = NS_NewLocalFile(aSoundAlias, PR_TRUE,
|
||||
// getter_AddRefs(soundFile));
|
||||
// NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
// rv = NS_NewFileURI(getter_AddRefs(fileURI), soundFile);
|
||||
|
|
|
@ -51,6 +51,8 @@
|
|||
#include "nsNetUtil.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
#include "nsNativeCharsetUtils.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsSound, nsISound, nsIStreamLoaderObserver)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
@ -209,17 +211,19 @@ NS_IMETHODIMP nsSound::Init()
|
|||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsSound::PlaySystemSound(const char *aSoundAlias)
|
||||
NS_IMETHODIMP nsSound::PlaySystemSound(const nsAString &aSoundAlias)
|
||||
{
|
||||
PurgeLastSound();
|
||||
|
||||
CWinMM& theMM = CWinMM::GetModule();
|
||||
|
||||
if (nsCRT::strcmp("_moz_mailbeep", aSoundAlias) == 0) {
|
||||
if (aSoundAlias.EqualsLiteral("_moz_mailbeep")) {
|
||||
theMM.PlaySound("MailBeep", nsnull, SND_ALIAS | SND_ASYNC);
|
||||
}
|
||||
else {
|
||||
theMM.PlaySound(aSoundAlias, nsnull, SND_ALIAS | SND_ASYNC);
|
||||
nsCAutoString nativeSoundAlias;
|
||||
NS_CopyUnicodeToNative(aSoundAlias, nativeSoundAlias);
|
||||
theMM.PlaySound(nativeSoundAlias.get(), nsnull, SND_ALIAS | SND_ASYNC);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -105,7 +105,7 @@ NS_METHOD nsSound::Play(nsIURL *aURL)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSound::PlaySystemSound(const char *aSoundAlias)
|
||||
NS_IMETHODIMP nsSound::PlaySystemSound(const nsAString &aSoundAlias)
|
||||
{
|
||||
return Beep();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче