Bug 1448914 - remove nsISound::playSystemSound; r=masayuki

This API is deprecated (callers are supposed to be using
nsISound::playEventSound instead) and there are no callers remaining in
mozilla-central, or references to the strings for the API.  Let's remove
dead code.
This commit is contained in:
Nathan Froyd 2018-03-27 10:41:40 -04:00
parent 806baa5430
commit 4d8cb59be3
6 changed files with 0 additions and 140 deletions

View File

@ -76,30 +76,6 @@ nsSound::Init()
return NS_OK;
}
NS_IMETHODIMP
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;
}
NSString *name = [NSString stringWithCharacters:reinterpret_cast<const unichar*>(aSoundAlias.BeginReading())
length:aSoundAlias.Length()];
NSSound *sound = [NSSound soundNamed:name];
if (sound) {
[sound stop];
[sound play];
}
return NS_OK;
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
}
NS_IMETHODIMP
nsSound::PlayEventSound(uint32_t aEventId)
{

View File

@ -417,43 +417,3 @@ NS_IMETHODIMP nsSound::PlayEventSound(uint32_t aEventId)
}
return NS_OK;
}
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");
uint32_t eventId;
if (aSoundAlias.Equals(NS_SYSSOUND_ALERT_DIALOG))
eventId = EVENT_ALERT_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_RECEIVED;
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;
// create a nsIFile and then a nsIFileURL from that
nsCOMPtr <nsIFile> soundFile;
rv = NS_NewLocalFile(aSoundAlias, true,
getter_AddRefs(soundFile));
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewFileURI(getter_AddRefs(fileURI), soundFile);
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(fileURI,&rv);
NS_ENSURE_SUCCESS(rv,rv);
rv = Play(fileURL);
return rv;
}

View File

@ -49,10 +49,5 @@ NS_IMETHODIMP HeadlessSound::PlayEventSound(uint32_t aEventId)
return NS_OK;
}
NS_IMETHODIMP HeadlessSound::PlaySystemSound(const nsAString &aSoundAlias)
{
return NS_OK;
}
} // namespace widget
} // namespace mozilla

View File

@ -12,13 +12,6 @@ interface nsIURL;
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();
/**
@ -45,23 +38,3 @@ interface nsISound : nsISupports
const unsigned long EVENT_EDITOR_MAX_LEN = 7;
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")
#define NS_SYSSOUND_CONFIRM_DIALOG NS_LITERAL_STRING("_moz_confirmdialog")
#define NS_SYSSOUND_PROMPT_DIALOG NS_LITERAL_STRING("_moz_promptdialog")
#define NS_SYSSOUND_SELECT_DIALOG NS_LITERAL_STRING("_moz_selectdialog")
#define NS_SYSSOUND_MENU_EXECUTE NS_LITERAL_STRING("_moz_menucommand")
#define NS_SYSSOUND_MENU_POPUP NS_LITERAL_STRING("_moz_menupopup")
#define NS_IsMozAliasSound(aSoundAlias) \
StringBeginsWith(aSoundAlias, NS_SYSSOUND_PREFIX)
%}

View File

@ -31,14 +31,6 @@ nsSoundProxy::Play(nsIURL *aURL)
return NS_OK;
}
NS_IMETHODIMP
nsSoundProxy::PlaySystemSound(const nsAString &aSoundAlias)
{
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Content);
MOZ_ASSERT(false, "PlaySystemSound is unimplemented.");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsSoundProxy::Beep()
{

View File

@ -274,42 +274,6 @@ NS_IMETHODIMP nsSound::Init()
return NS_OK;
}
NS_IMETHODIMP nsSound::PlaySystemSound(const nsAString &aSoundAlias)
{
MOZ_ASSERT(mPlayerThread, "player thread should not be null ");
PurgeLastSound();
if (!NS_IsMozAliasSound(aSoundAlias)) {
if (aSoundAlias.IsEmpty())
return NS_OK;
nsCOMPtr<nsIRunnable> player = new nsSoundPlayer(aSoundAlias);
MOZ_ASSERT(player, "Could not create player");
nsresult rv = mPlayerThread->Dispatch(player, NS_DISPATCH_NORMAL);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
return NS_OK;
}
NS_WARNING("nsISound::playSystemSound is called with \"_moz_\" events, they are obsolete, use nsISound::playEventSound instead");
uint32_t eventId;
if (aSoundAlias.Equals(NS_SYSSOUND_MAIL_BEEP))
eventId = EVENT_NEW_MAIL_RECEIVED;
else if (aSoundAlias.Equals(NS_SYSSOUND_CONFIRM_DIALOG))
eventId = EVENT_CONFIRM_DIALOG_OPEN;
else if (aSoundAlias.Equals(NS_SYSSOUND_ALERT_DIALOG))
eventId = EVENT_ALERT_DIALOG_OPEN;
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);
}
NS_IMETHODIMP nsSound::PlayEventSound(uint32_t aEventId)
{
MOZ_ASSERT(mPlayerThread, "player thread should not be null ");