NS_IMETHODIMP nsStatusBarBiffManager::OnItemIntPropertyChanged(nsIMsgFolder *item, nsIAtom *property, int32_t oldValue, int32_t newValue) { if (kBiffStateAtom == property && mCurrentBiffState != newValue) { // 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 (newValue == nsIMsgFolder::nsMsgBiffState_NewMail) { nsresult rv; nsCOMPtr<nsIPrefBranch> pref(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv)); NS_ENSURE_SUCCESS(rv, rv); bool playSoundOnBiff = false; rv = pref->GetBoolPref(PREF_PLAY_SOUND_ON_NEW_MAIL, &playSoundOnBiff); NS_ENSURE_SUCCESS(rv, rv); if (playSoundOnBiff) { // if we fail to play the biff sound, keep going. (void)PlayBiffSound(); } } mCurrentBiffState = newValue; // don't care if notification fails nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService(); if (observerService) observerService->NotifyObservers(static_cast<nsIStatusBarBiffManager*>(this), "mail:biff-state-changed", nullptr); } return NS_OK; }
// nsIObserver implementation NS_IMETHODIMP nsStatusBarBiffManager::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData) { nsresult rv; nsCOMPtr<nsIPrefBranch> pref(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv)); NS_ENSURE_SUCCESS(rv, rv); bool playSound = false; rv = pref->GetBoolPref(PREF_CHAT_PLAY_SOUND, &playSound); NS_ENSURE_SUCCESS(rv, rv); if (!playSound) return NS_OK; return PlayBiffSound(); }
NS_IMETHODIMP nsStatusBarBiffManager::OnItemIntPropertyChanged(nsIMsgFolder *item, nsIAtom *property, PRInt32 oldValue, PRInt32 newValue) { if (kBiffStateAtom == property && mCurrentBiffState != newValue) { // 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 (newValue == nsIMsgFolder::nsMsgBiffState_NewMail) { // if we fail to play the biff sound, keep going. (void)PlayBiffSound(); } mCurrentBiffState = newValue; // don't care if notification fails nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService(); if (observerService) observerService->NotifyObservers(this, "mail:biff-state-changed", nsnull); } return NS_OK; }