Bug 260865 Remove nsIAlertListener

patch by cst@andrew.cmu.edu r=jag sr=neil
This commit is contained in:
timeless%mozdev.org 2004-10-27 16:20:01 +00:00
Родитель 20aad1878f
Коммит 0d446f7283
7 изменённых файлов: 51 добавлений и 55 удалений

Просмотреть файл

@ -258,7 +258,7 @@ NS_INTERFACE_MAP_BEGIN(nsMessengerWinIntegration)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIMessengerOSIntegration)
NS_INTERFACE_MAP_ENTRY(nsIMessengerOSIntegration)
NS_INTERFACE_MAP_ENTRY(nsIFolderListener)
NS_INTERFACE_MAP_ENTRY(nsIAlertListener)
NS_INTERFACE_MAP_ENTRY(nsIObserver)
NS_INTERFACE_MAP_END
@ -484,20 +484,19 @@ nsresult nsMessengerWinIntegration::ShowAlertMessage(const PRUnichar * aAlertTit
nsCOMPtr<nsIAlertsService> alertsService (do_GetService(NS_ALERTSERVICE_CONTRACTID, &rv));
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIAlertListener> alertListener (do_QueryInterface(NS_STATIC_CAST(nsIMessengerOSIntegration*, this)));
rv = alertsService->ShowAlertNotification(NEW_MAIL_ALERT_ICON, aAlertTitle, aAlertText, PR_TRUE,
NS_ConvertASCIItoUCS2(aFolderURI).get(), alertListener);
NS_ConvertASCIItoUCS2(aFolderURI).get(), this);
mAlertInProgress = PR_TRUE;
}
}
if (!showAlert || NS_FAILED(rv)) // go straight to showing the system tray icon.
OnAlertFinished(nsnull);
AlertFinished();
return rv;
}
NS_IMETHODIMP nsMessengerWinIntegration::OnAlertFinished(const PRUnichar * aAlertCookie)
nsresult nsMessengerWinIntegration::AlertFinished()
{
// okay we are done showing the alert....now put an icon in the system tray
if (!mSuppressBiffIcon)
@ -511,7 +510,7 @@ NS_IMETHODIMP nsMessengerWinIntegration::OnAlertFinished(const PRUnichar * aAler
return NS_OK;
}
NS_IMETHODIMP nsMessengerWinIntegration::OnAlertClickCallback(const PRUnichar * aAlertCookie)
nsresult nsMessengerWinIntegration::AlertClicked()
{
// make sure we don't insert the icon in the system tray since the user clicked on the alert.
mSuppressBiffIcon = PR_TRUE;
@ -524,6 +523,18 @@ NS_IMETHODIMP nsMessengerWinIntegration::OnAlertClickCallback(const PRUnichar *
return NS_OK;
}
NS_IMETHODIMP
nsMessengerWinIntegration::Observe(nsISupports* aSubject, const char* aTopic, const PRUnichar* aData)
{
if (strcmp(aTopic, "alertfinished") == 0)
return AlertFinished();
if (strcmp(aTopic, "alertclickcallback") == 0)
return AlertClicked();
return NS_OK;
}
void nsMessengerWinIntegration::FillToolTipInfo()
{
// iterate over all the folders in mFoldersWithNewMail

Просмотреть файл

@ -56,6 +56,7 @@
#include "nsIPref.h"
#include "nsInt64.h"
#include "nsISupportsArray.h"
#include "nsIObserver.h"
// this function is exported by shell32.dll version 5.60 or later (Windows XP or greater)
extern "C"
@ -73,7 +74,7 @@ class nsIStringBundle;
class nsMessengerWinIntegration : public nsIMessengerOSIntegration,
public nsIFolderListener,
public nsIAlertListener
public nsIObserver
{
public:
nsMessengerWinIntegration();
@ -83,10 +84,12 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSIMESSENGEROSINTEGRATION
NS_DECL_NSIFOLDERLISTENER
NS_DECL_NSIALERTLISTENER
NS_DECL_NSIOBSERVER
private:
nsresult AlertFinished();
nsresult AlertClicked();
static NOTIFYICONDATAW mWideBiffIconData;
static NOTIFYICONDATA mAsciiBiffIconData;

Просмотреть файл

@ -38,32 +38,27 @@
#include "nsISupports.idl"
#include "nsIObserver.idl"
/* nsIAlertsListener --> when a consumer asks the alerts service to put up an alert, they have the option
of passing in an alert listener as well. The alert listener gets notified when the alert has gone away.
*/
[scriptable, uuid(A840623B-5B87-4e99-A74A-9EF0886C11DD)]
interface nsIAlertListener : nsISupports
{
void onAlertFinished(in wstring aAlertCookie);
void onAlertClickCallback(in wstring aAlertCookie); // if the user clicks the link and you wanted to be notified...
};
[scriptable, uuid(7E8B76C6-A70C-4075-81AA-D48B6152E1B4)]
[scriptable, uuid(3A3C2953-01EE-4D9C-A102-5AA0D7BD444C)]
interface nsIAlertsService : nsISupports
{
/* showAlertNotification: shows an animated alert icon
aImageUrl --> a url identifying an image to put in the alert.
aAlertTitle --> the title text for the alert (i.e. You have New Mail)
aAlertText --> the contents of the alert
alertTextClickable --> set to true if you wish to be notified if the user attempts to click
the alert text. Also causes the alert text to look like a link.
aAlertCookie --> a blind cookie the alert will pass back to the consumer during the alert listener callbacks
aAlertTitle --> the title text for the alert (i.e. You have New Mail)
aAlertText --> the contents of the alert
alertTextClickable --> set to true if you wish to be notified if the user attempts to click
the alert text. Also causes the alert text to look like a link.
aAlertCookie --> a blind cookie the alert will pass back to the consumer
during the alert listener callbacks
aAlertListener --> used for callbacks. Subject is null, topic is "alertfinished" when the
alert goes away, or "alertclickcallback" when the text is clicked. Data
is aAlertCookie.
*/
void showAlertNotification(in string aImageUrl, in wstring aAlertTitle,
in wstring aAlertText, in boolean alertTextClickable,
in wstring aAlertCookie,
in nsIAlertListener aAlertListener );
in wstring aAlertCookie,
in nsIObserver aAlertListener );
};
%{ C++

Просмотреть файл

@ -53,7 +53,7 @@ function prefillAlertInfo()
// arguments[2] --> the alert text
// arguments[3] --> is the text clickable?
// arguments[4] --> the alert cookie to be passed back to the listener
// arguments[5] --> an optional callback listener (nsIAlertListener)
// arguments[5] --> an optional callback listener (nsIObserver)
document.getElementById('alertImage').setAttribute('src', window.arguments[0]);
document.getElementById('alertTitleLabel').setAttribute('value', window.arguments[1]);
@ -65,8 +65,7 @@ function prefillAlertInfo()
document.getElementById('alertTextLabel').setAttribute('clickable', true);
// the 5th argument is optional
if (window.arguments[5])
gAlertListener = window.arguments[5].QueryInterface(Components.interfaces.nsIAlertListener);
gAlertListener = window.arguments[5];
}
function onAlertLoad()
@ -117,7 +116,7 @@ function closeAlert()
else
{
if (gAlertListener)
gAlertListener.onAlertFinished(gAlertCookie);
gAlertListener.observe(null, "alertfinished", gAlertCookie);
window.close();
}
}
@ -125,5 +124,5 @@ function closeAlert()
function onAlertClick()
{
if (gAlertListener && gAlertTextClickable)
gAlertListener.onAlertClickCallback(gAlertCookie);
gAlertListener.observe(null, "alertclickcallback", gAlertCookie);
}

Просмотреть файл

@ -65,7 +65,7 @@ nsAlertsService::~nsAlertsService()
NS_IMETHODIMP nsAlertsService::ShowAlertNotification(const char * aImageUrl, const PRUnichar * aAlertTitle,
const PRUnichar * aAlertText, PRBool aAlertTextClickable,
const PRUnichar * aAlertCookie,
nsIAlertListener * aAlertListener)
nsIObserver * aAlertListener)
{
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
nsCOMPtr<nsIDOMWindow> newWindow;
@ -113,7 +113,7 @@ NS_IMETHODIMP nsAlertsService::ShowAlertNotification(const char * aImageUrl, con
nsCOMPtr<nsISupports> iSupports (do_QueryInterface(aAlertListener));
ifptr->SetData(iSupports);
ifptr->SetDataIID(&NS_GET_IID(nsIAlertListener));
ifptr->SetDataIID(&NS_GET_IID(nsIObserver));
argsArray->AppendElement(ifptr);
}

Просмотреть файл

@ -919,7 +919,7 @@ nsDownloadManager::Observe(nsISupports* aSubject, const char* aTopic, const PRUn
///////////////////////////////////////////////////////////////////////////////
// nsDownload
NS_IMPL_ISUPPORTS5(nsDownload, nsIDownload, nsITransfer, nsIWebProgressListener, nsIObserver, nsIAlertListener)
NS_IMPL_ISUPPORTS4(nsDownload, nsIDownload, nsITransfer, nsIWebProgressListener, nsIObserver)
nsDownload::nsDownload(nsDownloadManager* aManager,
nsIURI* aTarget,
@ -982,6 +982,13 @@ nsDownload::Observe(nsISupports* aSubject, const char* aTopic, const PRUnichar*
mDownloadManager->CancelDownload(path);
// Ignoring return value; this function will get called twice,
// and bad things happen if we return a failure code the second time.
return NS_OK;
}
if (strcmp(aTopic, "alertclickcallback") == 0) {
// show the download manager
mDownloadManager->Open(nsnull, this);
return NS_OK;
}
return NS_OK;
@ -1269,23 +1276,6 @@ nsDownload::OnSecurityChange(nsIWebProgress *aWebProgress,
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////////
// nsIAlertListener
NS_IMETHODIMP
nsDownload::OnAlertFinished(const PRUnichar * aAlertCookie)
{
return NS_OK;
}
NS_IMETHODIMP
nsDownload::OnAlertClickCallback(const PRUnichar * aAlertCookie)
{
// show the download manager
mDownloadManager->Open(nsnull, this);
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////////
// nsIDownload

Просмотреть файл

@ -106,8 +106,7 @@ private:
class nsDownload : public nsIDownload,
public nsIWebProgressListener,
public nsIObserver,
public nsIAlertListener
public nsIObserver
{
public:
NS_DECL_NSIWEBPROGRESSLISTENER
@ -115,7 +114,6 @@ public:
NS_DECL_NSIDOWNLOAD
NS_DECL_NSIOBSERVER
NS_DECL_ISUPPORTS
NS_DECL_NSIALERTLISTENER
nsDownload(nsDownloadManager* aManager, nsIURI* aTarget, nsIURI* aSource);
~nsDownload();