зеркало из https://github.com/mozilla/pjs.git
Bug 502799 add new nsISound method for the event sounds r=roc+neil, sr=roc
This commit is contained in:
Родитель
5aae8d51d9
Коммит
0a0f6e7662
|
@ -43,17 +43,19 @@
|
|||
interface nsIDOMWindow;
|
||||
interface nsIDialogParamBlock;
|
||||
|
||||
[uuid(d16e906d-bab3-49e0-8688-7f49a6f4293a)]
|
||||
[uuid(C60A1955-6CB3-4827-8EF8-4F5C668AF0B3)]
|
||||
interface nsPIPromptService : nsISupports
|
||||
{
|
||||
%{C++
|
||||
// eOpeningSound is obsolete but we need to support it for the compatibility.
|
||||
// The implementers should use eSoundEventId instead.
|
||||
enum {eMsg=0, eCheckboxMsg=1, eIconClass=2, eTitleMessage=3, eEditfield1Msg=4,
|
||||
eEditfield2Msg=5, eEditfield1Value=6, eEditfield2Value=7,
|
||||
eButton0Text=8, eButton1Text=9, eButton2Text=10, eButton3Text=11,
|
||||
eDialogTitle=12, eOpeningSound=13};
|
||||
enum {eButtonPressed=0, eCheckboxState=1, eNumberButtons=2,
|
||||
eNumberEditfields=3, eEditField1Password=4, eDefaultButton=5,
|
||||
eDelayButtonEnable=6};
|
||||
eDelayButtonEnable=6, eSoundEventId=7};
|
||||
%}
|
||||
|
||||
void doDialog(in nsIDOMWindow aParent, in nsIDialogParamBlock aParamBlock, in string aChromeURL);
|
||||
|
|
|
@ -141,6 +141,7 @@ nsPromptService::Alert(nsIDOMWindow *parent,
|
|||
NS_ConvertASCIItoUTF16 styleClass(kAlertIconClass);
|
||||
block->SetString(eIconClass, styleClass.get());
|
||||
block->SetString(eOpeningSound, NS_SYSSOUND_ALERT_DIALOG.get());
|
||||
block->SetInt(eSoundEventId, nsISound::EVENT_AELRT_DIALOG_OPEN);
|
||||
|
||||
rv = DoDialog(parent, block, kPromptURL);
|
||||
|
||||
|
@ -186,6 +187,7 @@ nsPromptService::AlertCheck(nsIDOMWindow *parent,
|
|||
block->SetString(eCheckboxMsg, checkMsg);
|
||||
block->SetInt(eCheckboxState, *checkValue);
|
||||
block->SetString(eOpeningSound, NS_SYSSOUND_ALERT_DIALOG.get());
|
||||
block->SetInt(eSoundEventId, nsISound::EVENT_AELRT_DIALOG_OPEN);
|
||||
|
||||
rv = DoDialog(parent, block, kPromptURL);
|
||||
if (NS_FAILED(rv))
|
||||
|
@ -232,6 +234,7 @@ nsPromptService::Confirm(nsIDOMWindow *parent,
|
|||
NS_ConvertASCIItoUTF16 styleClass(kQuestionIconClass);
|
||||
block->SetString(eIconClass, styleClass.get());
|
||||
block->SetString(eOpeningSound, NS_SYSSOUND_CONFIRM_DIALOG.get());
|
||||
block->SetInt(eSoundEventId, nsISound::EVENT_CONFIRM_DIALOG_OPEN);
|
||||
|
||||
rv = DoDialog(parent, block, kPromptURL);
|
||||
if (NS_FAILED(rv))
|
||||
|
@ -282,6 +285,7 @@ nsPromptService::ConfirmCheck(nsIDOMWindow *parent,
|
|||
block->SetString(eCheckboxMsg, checkMsg);
|
||||
block->SetInt(eCheckboxState, *checkValue);
|
||||
block->SetString(eOpeningSound, NS_SYSSOUND_CONFIRM_DIALOG.get());
|
||||
block->SetInt(eSoundEventId, nsISound::EVENT_CONFIRM_DIALOG_OPEN);
|
||||
|
||||
rv = DoDialog(parent, block, kPromptURL);
|
||||
if (NS_FAILED(rv))
|
||||
|
@ -384,6 +388,7 @@ nsPromptService::ConfirmEx(nsIDOMWindow *parent,
|
|||
|
||||
block->SetString(eIconClass, NS_ConvertASCIItoUTF16(kQuestionIconClass).get());
|
||||
block->SetString(eOpeningSound, NS_SYSSOUND_CONFIRM_DIALOG.get());
|
||||
block->SetInt(eSoundEventId, nsISound::EVENT_CONFIRM_DIALOG_OPEN);
|
||||
|
||||
if (checkMsg && checkValue) {
|
||||
block->SetString(eCheckboxMsg, checkMsg);
|
||||
|
@ -460,6 +465,7 @@ nsPromptService::Prompt(nsIDOMWindow *parent,
|
|||
block->SetInt(eCheckboxState, *checkValue);
|
||||
}
|
||||
block->SetString(eOpeningSound, NS_SYSSOUND_PROMPT_DIALOG.get());
|
||||
block->SetInt(eSoundEventId, nsISound::EVENT_PROMPT_DIALOG_OPEN);
|
||||
|
||||
rv = DoDialog(parent, block, kPromptURL);
|
||||
if (NS_FAILED(rv))
|
||||
|
@ -536,6 +542,7 @@ nsPromptService::PromptUsernameAndPassword(nsIDOMWindow *parent,
|
|||
block->SetInt(eCheckboxState, *checkValue);
|
||||
}
|
||||
block->SetString(eOpeningSound, NS_SYSSOUND_PROMPT_DIALOG.get());
|
||||
block->SetInt(eSoundEventId, nsISound::EVENT_PROMPT_DIALOG_OPEN);
|
||||
|
||||
rv = DoDialog(parent, block, kPromptURL);
|
||||
if (NS_FAILED(rv))
|
||||
|
@ -616,6 +623,7 @@ NS_IMETHODIMP nsPromptService::PromptPassword(nsIDOMWindow *parent,
|
|||
block->SetInt(eCheckboxState, *checkValue);
|
||||
}
|
||||
block->SetString(eOpeningSound, NS_SYSSOUND_PROMPT_DIALOG.get());
|
||||
block->SetInt(eSoundEventId, nsISound::EVENT_PROMPT_DIALOG_OPEN);
|
||||
|
||||
rv = DoDialog(parent, block, kPromptURL);
|
||||
if (NS_FAILED(rv))
|
||||
|
@ -751,6 +759,7 @@ nsPromptService::ShowNonBlockingAlert(nsIDOMWindow *aParent,
|
|||
paramBlock->SetString(eDialogTitle, aDialogTitle);
|
||||
paramBlock->SetString(eMsg, aText);
|
||||
paramBlock->SetString(eOpeningSound, NS_SYSSOUND_ALERT_DIALOG.get());
|
||||
paramBlock->SetInt(eSoundEventId, nsISound::EVENT_AELRT_DIALOG_OPEN);
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> dialog;
|
||||
mWatcher->OpenWindow(aParent, "chrome://global/content/commonDialog.xul",
|
||||
|
|
|
@ -1181,7 +1181,7 @@ nsMenuFrame::Execute(nsGUIEvent *aEvent)
|
|||
|
||||
nsCOMPtr<nsISound> sound(do_CreateInstance("@mozilla.org/sound;1"));
|
||||
if (sound)
|
||||
sound->PlaySystemSound(NS_SYSSOUND_MENU_EXECUTE);
|
||||
sound->PlayEventSound(nsISound::EVENT_MENU_EXECUTE);
|
||||
|
||||
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
|
||||
if (pm && mMenuParent)
|
||||
|
|
|
@ -637,7 +637,7 @@ nsMenuPopupFrame::ShowPopup(PRBool aIsContextMenu, PRBool aSelectFirstItem)
|
|||
if (mPopupType == ePopupTypeMenu) {
|
||||
nsCOMPtr<nsISound> sound(do_CreateInstance("@mozilla.org/sound;1"));
|
||||
if (sound)
|
||||
sound->PlaySystemSound(NS_SYSSOUND_MENU_POPUP);
|
||||
sound->PlayEventSound(nsISound::EVENT_MENU_POPUP);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -231,11 +231,11 @@ function commonDialogOnLoad()
|
|||
|
||||
// play sound
|
||||
try {
|
||||
var sound = gCommonDialogParam.GetString(13);
|
||||
var sound = gCommonDialogParam.GetInt(7);
|
||||
if (sound) {
|
||||
Cc["@mozilla.org/sound;1"]
|
||||
.createInstance(Ci.nsISound)
|
||||
.playSystemSound(sound);
|
||||
.playEventSound(sound);
|
||||
}
|
||||
} catch (e) { }
|
||||
}
|
||||
|
|
|
@ -101,9 +101,10 @@ function selectDialogOnLoad() {
|
|||
|
||||
// play sound
|
||||
try {
|
||||
const nsISound = Components.interfaces.nsISound;
|
||||
Components.classes["@mozilla.org/sound;1"]
|
||||
.createInstance(Components.interfaces.nsISound)
|
||||
.playSystemSound("_moz_selectdialog");
|
||||
.createInstance(nsISound)
|
||||
.playEventSound(nsISound.EVENT_SELECT_DIALOG_OPEN);
|
||||
} catch (e) { }
|
||||
}
|
||||
|
||||
|
|
|
@ -41,12 +41,15 @@
|
|||
|
||||
interface nsIURL;
|
||||
|
||||
[scriptable, uuid(B01ADAD7-D937-4738-8508-3BD5946BF9C8)]
|
||||
[scriptable, uuid(53FC43F2-26BC-46be-8E38-1BBA94806061)]
|
||||
interface nsISound : nsISupports
|
||||
{
|
||||
void play(in nsIURL aURL);
|
||||
/**
|
||||
* for playing system sounds
|
||||
*
|
||||
* NS_SYSSOUND_* params are obsolete. The new events will not be supported by
|
||||
* this method. You should use playEventSound method instaed.
|
||||
*/
|
||||
void playSystemSound(in AString soundAlias);
|
||||
void beep();
|
||||
|
@ -56,10 +59,31 @@ interface nsISound : nsISupports
|
|||
* The various methods on nsISound call Init() if they need to.
|
||||
*/
|
||||
void init();
|
||||
|
||||
/**
|
||||
* In some situations, playEventSound will be called. Then, each
|
||||
* implementations will play a system sound for the event if it's necessary.
|
||||
*
|
||||
* NOTE: Don't change these values because they are used in
|
||||
* nsPIPromptService.idl. So, if they are changed, that makes big impact for
|
||||
* the embedders.
|
||||
*/
|
||||
const unsigned long EVENT_NEW_MAIL_RECIEVED = 0;
|
||||
const unsigned long EVENT_AELRT_DIALOG_OPEN = 1;
|
||||
const unsigned long EVENT_CONFIRM_DIALOG_OPEN = 2;
|
||||
const unsigned long EVENT_PROMPT_DIALOG_OPEN = 3;
|
||||
const unsigned long EVENT_SELECT_DIALOG_OPEN = 4;
|
||||
const unsigned long EVENT_MENU_EXECUTE = 5;
|
||||
const unsigned long EVENT_MENU_POPUP = 6;
|
||||
void playEventSound(in unsigned long aEventId);
|
||||
};
|
||||
|
||||
%{C++
|
||||
|
||||
/**
|
||||
* NS_SYSSOUND_* can be used for playSystemSound but they are obsolete.
|
||||
* Use nsISound::playEventSound instead.
|
||||
*/
|
||||
#define NS_SYSSOUND_PREFIX NS_LITERAL_STRING("_moz_")
|
||||
#define NS_SYSSOUND_MAIL_BEEP NS_LITERAL_STRING("_moz_mailbeep")
|
||||
#define NS_SYSSOUND_ALERT_DIALOG NS_LITERAL_STRING("_moz_alertdialog")
|
||||
|
|
|
@ -154,6 +154,7 @@ NS_IMETHODIMP nsSound::PlaySystemSound(const nsAString &aSoundAlias)
|
|||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
if (NS_IsMozAliasSound(aSoundAlias)) {
|
||||
NS_WARNING("nsISound::playSystemSound is called with \"_moz_\" events, they are obsolete, use nsISound::playEventSound instead");
|
||||
if (aSoundAlias.Equals(NS_SYSSOUND_MAIL_BEEP))
|
||||
return Beep();
|
||||
return NS_OK;
|
||||
|
@ -171,3 +172,8 @@ NS_IMETHODIMP nsSound::PlaySystemSound(const nsAString &aSoundAlias)
|
|||
rv = Play(fileURL);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSound::PlayEventSound(PRUint32 aEventId)
|
||||
{
|
||||
return aEventId == EVENT_NEW_MAIL_RECIEVED ? Beep() : NS_OK;
|
||||
}
|
||||
|
|
|
@ -110,6 +110,7 @@ nsSound::PlaySystemSound(const nsAString &aSoundAlias)
|
|||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
||||
if (NS_IsMozAliasSound(aSoundAlias)) {
|
||||
NS_WARNING("nsISound::playSystemSound is called with \"_moz_\" events, they are obsolete, use nsISound::playEventSound instead");
|
||||
// Mac doesn't have system sound settings for each user actions.
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -126,3 +127,10 @@ nsSound::PlaySystemSound(const nsAString &aSoundAlias)
|
|||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSound::PlayEventSound(PRUint32 aEventId)
|
||||
{
|
||||
// Mac doesn't have system sound settings for each user actions.
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -438,7 +438,7 @@ NS_METHOD nsSound::Play(nsIURL *aURL)
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsSound::PlaySystemEventSound(const nsAString &aSoundAlias)
|
||||
NS_IMETHODIMP nsSound::PlayEventSound(PRUint32 aEventId)
|
||||
{
|
||||
if (!libcanberra)
|
||||
return NS_OK;
|
||||
|
@ -481,17 +481,23 @@ nsresult nsSound::PlaySystemEventSound(const nsAString &aSoundAlias)
|
|||
g_free(sound_theme_name);
|
||||
}
|
||||
|
||||
if (aSoundAlias.Equals(NS_SYSSOUND_ALERT_DIALOG))
|
||||
ca_context_play(ctx, 0, "event.id", "dialog-warning", NULL);
|
||||
else if (aSoundAlias.Equals(NS_SYSSOUND_CONFIRM_DIALOG))
|
||||
ca_context_play(ctx, 0, "event.id", "dialog-question", NULL);
|
||||
else if (aSoundAlias.Equals(NS_SYSSOUND_MAIL_BEEP))
|
||||
ca_context_play(ctx, 0, "event.id", "message-new-email", NULL);
|
||||
else if (aSoundAlias.Equals(NS_SYSSOUND_MENU_EXECUTE))
|
||||
ca_context_play(ctx, 0, "event.id", "menu-click", NULL);
|
||||
else if (aSoundAlias.Equals(NS_SYSSOUND_MENU_POPUP))
|
||||
ca_context_play(ctx, 0, "event.id", "menu-popup", NULL);
|
||||
|
||||
switch (aEventId) {
|
||||
case EVENT_AELRT_DIALOG_OPEN:
|
||||
ca_context_play(ctx, 0, "event.id", "dialog-warning", NULL);
|
||||
break;
|
||||
case EVENT_CONFIRM_DIALOG_OPEN:
|
||||
ca_context_play(ctx, 0, "event.id", "dialog-question", NULL);
|
||||
break;
|
||||
case EVENT_NEW_MAIL_RECIEVED:
|
||||
ca_context_play(ctx, 0, "event.id", "message-new-email", NULL);
|
||||
break;
|
||||
case EVENT_MENU_EXECUTE:
|
||||
ca_context_play(ctx, 0, "event.id", "menu-click", NULL);
|
||||
break;
|
||||
case EVENT_MENU_POPUP:
|
||||
ca_context_play(ctx, 0, "event.id", "menu-popup", NULL);
|
||||
break;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -500,8 +506,23 @@ NS_IMETHODIMP nsSound::PlaySystemSound(const nsAString &aSoundAlias)
|
|||
if (!mInited)
|
||||
Init();
|
||||
|
||||
if (NS_IsMozAliasSound(aSoundAlias))
|
||||
return PlaySystemEventSound(aSoundAlias);
|
||||
if (NS_IsMozAliasSound(aSoundAlias)) {
|
||||
NS_WARNING("nsISound::playSystemSound is called with \"_moz_\" events, they are obsolete, use nsISound::playEventSound instead");
|
||||
PRUint32 eventId;
|
||||
if (aSoundAlias.Equals(NS_SYSSOUND_ALERT_DIALOG))
|
||||
eventId = EVENT_AELRT_DIALOG_OPEN;
|
||||
else if (aSoundAlias.Equals(NS_SYSSOUND_CONFIRM_DIALOG))
|
||||
eventId = EVENT_CONFIRM_DIALOG_OPEN;
|
||||
else if (aSoundAlias.Equals(NS_SYSSOUND_MAIL_BEEP))
|
||||
eventId = EVENT_NEW_MAIL_RECIEVED;
|
||||
else if (aSoundAlias.Equals(NS_SYSSOUND_MENU_EXECUTE))
|
||||
eventId = EVENT_MENU_EXECUTE;
|
||||
else if (aSoundAlias.Equals(NS_SYSSOUND_MENU_POPUP))
|
||||
eventId = EVENT_MENU_POPUP;
|
||||
else
|
||||
return NS_OK;
|
||||
return PlayEventSound(eventId);
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr <nsIURI> fileURI;
|
||||
|
|
|
@ -60,8 +60,6 @@ public:
|
|||
NS_DECL_NSISTREAMLOADEROBSERVER
|
||||
|
||||
private:
|
||||
nsresult PlaySystemEventSound(const nsAString &aSoundAlias);
|
||||
|
||||
PRBool mInited;
|
||||
|
||||
};
|
||||
|
|
|
@ -488,6 +488,7 @@ NS_IMETHODIMP nsSound::PlaySystemSound(const nsAString &aSoundAlias)
|
|||
}
|
||||
|
||||
if (NS_IsMozAliasSound(aSoundAlias)) {
|
||||
NS_WARNING("nsISound::playSystemSound is called with \"_moz_\" events, they are obsolete, use nsISound::playEventSound instead");
|
||||
// We don't have a default mail sound on OS/2, so just beep.
|
||||
if (aSoundAlias.Equals(NS_SYSSOUND_MAIL_BEEP))
|
||||
Beep();
|
||||
|
@ -511,3 +512,14 @@ NS_IMETHODIMP nsSound::PlaySystemSound(const nsAString &aSoundAlias)
|
|||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSound::PlayEventSound(PRUint32 aEventId)
|
||||
{
|
||||
// Just beep if MMPM isn't installed.
|
||||
if (!sMMPMInstalled) {
|
||||
return Beep();
|
||||
}
|
||||
|
||||
// We don't have a default mail sound on OS/2, so just beep.
|
||||
return aEventId == EVENT_NEW_MAIL_RECIEVED ? Beep() : NS_OK;
|
||||
}
|
||||
|
|
|
@ -119,6 +119,7 @@ printf( "\n\n\nnsSound::PlaySystemSound aSoundAlias=%s\n\n",
|
|||
const char *soundfile;
|
||||
|
||||
if( NS_IsMozAliasSound(aSoundAlias) ) {
|
||||
NS_WARNING("nsISound::playSystemSound is called with \"_moz_\" events, they are obsolete, use nsISound::playEventSound instead");
|
||||
if ( aSoundAlias.Equals(NS_SYSSOUND_MAIL_BEEP) )
|
||||
soundfile = "/usr/share/mozilla/gotmail.wav";
|
||||
else
|
||||
|
@ -137,3 +138,18 @@ printf( "\n\n\nnsSound::PlaySystemSound aSoundAlias=%s\n\n",
|
|||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSound::PlayEventSound(PRUint32 aEventId)
|
||||
{
|
||||
if (aEventId != EVENT_NEW_MAIL_RECIEVED) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
soundfile = "/usr/share/mozilla/gotmail.wav";
|
||||
const char* argv[] = { "/opt/Mozilla/mozilla/wave",
|
||||
"/usr/share/mozilla/gotmail.wav", NULL };
|
||||
PtSpawn( "/opt/Mozilla/mozilla/wave", ( const char ** ) argv,
|
||||
NULL, NULL, child_exit, NULL, NULL );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -379,6 +379,7 @@ NS_METHOD nsSound::Play(nsIURL *aURL)
|
|||
NS_IMETHODIMP nsSound::PlaySystemSound(const nsAString &aSoundAlias)
|
||||
{
|
||||
if (NS_IsMozAliasSound(aSoundAlias)) {
|
||||
NS_WARNING("nsISound::playSystemSound is called with \"_moz_\" events, they are obsolete, use nsISound::playEventSound instead");
|
||||
if (aSoundAlias.Equals(NS_SYSSOUND_MAIL_BEEP))
|
||||
return Beep();
|
||||
return NS_OK;
|
||||
|
@ -403,3 +404,9 @@ NS_IMETHODIMP nsSound::PlaySystemSound(const nsAString &aSoundAlias)
|
|||
return rv;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSound::PlayEventSound(PRUint32 aEventId)
|
||||
{
|
||||
return aEventId == EVENT_NEW_MAIL_RECIEVED ? Beep() : NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -246,26 +246,56 @@ NS_IMETHODIMP nsSound::PlaySystemSound(const nsAString &aSoundAlias)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// Win32 plays no sounds at NS_SYSSOUND_PROMPT_DIALOG and
|
||||
// NS_SYSSOUND_SELECT_DIALOG.
|
||||
const wchar_t *sound = nsnull;
|
||||
NS_WARNING("nsISound::playSystemSound is called with \"_moz_\" events, they are obsolete, use nsISound::playEventSound instead");
|
||||
|
||||
PRUint32 eventId;
|
||||
if (aSoundAlias.Equals(NS_SYSSOUND_MAIL_BEEP))
|
||||
sound = L"MailBeep";
|
||||
eventId = EVENT_NEW_MAIL_RECIEVED;
|
||||
else if (aSoundAlias.Equals(NS_SYSSOUND_CONFIRM_DIALOG))
|
||||
sound = L"SystemQuestion";
|
||||
eventId = EVENT_CONFIRM_DIALOG_OPEN;
|
||||
else if (aSoundAlias.Equals(NS_SYSSOUND_ALERT_DIALOG))
|
||||
sound = L"SystemExclamation";
|
||||
eventId = EVENT_AELRT_DIALOG_OPEN;
|
||||
else if (aSoundAlias.Equals(NS_SYSSOUND_MENU_EXECUTE))
|
||||
sound = L"MenuCommand";
|
||||
eventId = EVENT_MENU_EXECUTE;
|
||||
else if (aSoundAlias.Equals(NS_SYSSOUND_MENU_POPUP))
|
||||
sound = L"MenuPopup";
|
||||
eventId = EVENT_MENU_POPUP;
|
||||
else
|
||||
return NS_OK;
|
||||
|
||||
return PlayEventSound(eventId);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSound::PlayEventSound(PRUint32 aEventId)
|
||||
{
|
||||
PurgeLastSound();
|
||||
|
||||
const wchar_t *sound = nsnull;
|
||||
switch (aEventId) {
|
||||
case EVENT_NEW_MAIL_RECIEVED:
|
||||
sound = L"MailBeep";
|
||||
break;
|
||||
case EVENT_AELRT_DIALOG_OPEN:
|
||||
sound = L"SystemExclamation";
|
||||
break;
|
||||
case EVENT_CONFIRM_DIALOG_OPEN:
|
||||
sound = L"SystemQuestion";
|
||||
break;
|
||||
case EVENT_MENU_EXECUTE:
|
||||
sound = L"MenuCommand";
|
||||
break;
|
||||
case EVENT_MENU_POPUP:
|
||||
sound = L"MenuPopup";
|
||||
break;
|
||||
default:
|
||||
// Win32 plays no sounds at NS_SYSSOUND_PROMPT_DIALOG and
|
||||
// NS_SYSSOUND_SELECT_DIALOG.
|
||||
return NS_OK;
|
||||
}
|
||||
NS_ASSERTION(sound, "sound is null");
|
||||
|
||||
nsCOMPtr<nsIRunnable> player = new nsSoundPlayer(this, sound);
|
||||
NS_ENSURE_TRUE(player, NS_ERROR_OUT_OF_MEMORY);
|
||||
nsresult rv = NS_NewThread(getter_AddRefs(mPlayerThread), player);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче