зеркало из https://github.com/mozilla/pjs.git
Bug #332160 --> hook up new mail alert notifications for unix.
Patch by magnus melin <mkmelin+mozilla@iki.fi> sr=mscott
This commit is contained in:
Родитель
321ad66a71
Коммит
db42881ff8
|
@ -37,6 +37,9 @@
|
|||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
<?xml-stylesheet href="chrome://messenger/skin/newmailalert.css" type="text/css"?>
|
||||
#ifdef XP_UNIX
|
||||
<?xml-stylesheet href="chrome://messenger/skin/newMailAlertUnix.css" type="text/css"?>
|
||||
#endif
|
||||
|
||||
<window id="newMailAlertNotification"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
|
|
|
@ -26,6 +26,7 @@ classic.jar:
|
|||
skin/classic/messenger/filterDialog.css
|
||||
skin/classic/messenger/dialogs.css
|
||||
skin/classic/messenger/newmailalert.css
|
||||
skin/classic/messenger/newMailAlertUnix.css
|
||||
skin/classic/messenger/addressbook/addressbook.css (addrbook/addressbook.css)
|
||||
skin/classic/messenger/addressbook/abContactsPanel.css (addrbook/abContactsPanel.css)
|
||||
skin/classic/messenger/addressbook/cardDialog.css (addrbook/cardDialog.css)
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
/* ===== newMailAlertUnix.css ===============================================
|
||||
== Styles specific to the unix alerts dialog.
|
||||
== See bug 332160 on the problem this fixes.
|
||||
======================================================================= */
|
||||
|
||||
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
|
||||
|
||||
/* Reset the default CSS rules for #newMailAlertNotification. */
|
||||
#newMailAlertNotification {
|
||||
min-height: inherit;
|
||||
border: none;
|
||||
background-color: inherit;
|
||||
}
|
||||
|
||||
/* Apply the default CSS rules of #newMailAlertNotification on #alertContainer instead. */
|
||||
#alertContainer {
|
||||
min-height: 60px;
|
||||
border: ridge #5486DA 4px;
|
||||
background-color: white;
|
||||
}
|
||||
|
|
@ -169,6 +169,7 @@ nsresult nsMessengerUnixIntegration::GetStringBundle(nsIStringBundle **aBundle)
|
|||
return rv;
|
||||
}
|
||||
|
||||
#ifndef MOZ_THUNDERBIRD
|
||||
nsresult nsMessengerUnixIntegration::ShowAlertMessage(const PRUnichar * aAlertTitle, const PRUnichar * aAlertText, const char * aFolderURI)
|
||||
{
|
||||
nsresult rv;
|
||||
|
@ -200,6 +201,68 @@ nsresult nsMessengerUnixIntegration::ShowAlertMessage(const PRUnichar * aAlertTi
|
|||
|
||||
return rv;
|
||||
}
|
||||
#else
|
||||
// Opening Thunderbird's new mail alert notification window
|
||||
// aUserInitiated --> true if we are opening the alert notification in response to a user action
|
||||
// like clicking on the biff icon
|
||||
nsresult nsMessengerUnixIntegration::ShowNewAlertNotification(PRBool aUserInitiated)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// if we are already in the process of showing an alert, don't try to show another....
|
||||
if (mAlertInProgress)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
||||
PRBool showAlert = PR_TRUE;
|
||||
|
||||
if (prefBranch)
|
||||
prefBranch->GetBoolPref(SHOW_ALERT_PREF, &showAlert);
|
||||
|
||||
if (showAlert)
|
||||
{
|
||||
nsCOMPtr<nsISupportsArray> argsArray;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(argsArray));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// pass in the array of folders with unread messages
|
||||
nsCOMPtr<nsISupportsInterfacePointer> ifptr = do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
ifptr->SetData(mFoldersWithNewMail);
|
||||
ifptr->SetDataIID(&NS_GET_IID(nsISupportsArray));
|
||||
argsArray->AppendElement(ifptr);
|
||||
|
||||
// pass in the observer
|
||||
ifptr = do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr <nsISupports> supports = do_QueryInterface(NS_STATIC_CAST(nsIMessengerOSIntegration*, this));
|
||||
ifptr->SetData(supports);
|
||||
ifptr->SetDataIID(&NS_GET_IID(nsIObserver));
|
||||
argsArray->AppendElement(ifptr);
|
||||
|
||||
// pass in the animation flag
|
||||
nsCOMPtr<nsISupportsPRBool> scriptableUserInitiated (do_CreateInstance(NS_SUPPORTS_PRBOOL_CONTRACTID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
scriptableUserInitiated->SetData(aUserInitiated);
|
||||
argsArray->AppendElement(scriptableUserInitiated);
|
||||
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
|
||||
nsCOMPtr<nsIDOMWindow> newWindow;
|
||||
rv = wwatch->OpenWindow(0, ALERT_CHROME_URL, "_blank",
|
||||
"chrome,dialog=yes,titlebar=no,popup=yes", argsArray,
|
||||
getter_AddRefs(newWindow));
|
||||
|
||||
mAlertInProgress = PR_TRUE;
|
||||
}
|
||||
|
||||
// if the user has turned off the mail alert, or openWindow generated an error,
|
||||
// then go straight to the system tray.
|
||||
if (!showAlert || NS_FAILED(rv))
|
||||
AlertFinished();
|
||||
|
||||
return rv;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsresult nsMessengerUnixIntegration::AlertFinished()
|
||||
{
|
||||
|
@ -259,7 +322,11 @@ void nsMessengerUnixIntegration::FillToolTipInfo()
|
|||
else
|
||||
bundle->FormatStringFromName(NS_LITERAL_STRING("biffNotification_messages").get(), formatStrings, 1, getter_Copies(finalText));
|
||||
|
||||
#ifndef MOZ_THUNDERBIRD
|
||||
ShowAlertMessage(accountName, finalText, "");
|
||||
#else
|
||||
ShowNewAlertNotification(PR_FALSE);
|
||||
#endif
|
||||
} // if we got a bundle
|
||||
} // if we got a folder
|
||||
}
|
||||
|
|
|
@ -67,8 +67,14 @@ public:
|
|||
NS_DECL_NSIFOLDERLISTENER
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
#ifdef MOZ_THUNDERBIRD
|
||||
nsresult ShowNewAlertNotification(PRBool aUserInitiated);
|
||||
#endif
|
||||
|
||||
private:
|
||||
#ifndef MOZ_THUNDERBIRD
|
||||
nsresult ShowAlertMessage(const PRUnichar * aAlertTitle, const PRUnichar * aAlertText, const char * aFolderURI);
|
||||
#endif
|
||||
nsresult GetFirstFolderWithNewMail(char ** aFolderURI);
|
||||
nsresult GetStringBundle(nsIStringBundle **aBundle);
|
||||
nsresult AlertFinished();
|
||||
|
|
|
@ -114,6 +114,9 @@
|
|||
#ifdef XP_MACOSX
|
||||
#include "nsMessengerOSXIntegration.h"
|
||||
#endif
|
||||
#if defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_GTK2)
|
||||
#include "nsMessengerUnixIntegration.h"
|
||||
#endif
|
||||
#include "nsCURILoader.h"
|
||||
#include "nsMessengerContentHandler.h"
|
||||
|
||||
|
@ -341,6 +344,9 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMessengerOS2Integration, Init)
|
|||
#ifdef XP_MACOSX
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMessengerOSXIntegration, Init)
|
||||
#endif
|
||||
#if defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_GTK2)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMessengerUnixIntegration, Init)
|
||||
#endif
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMessengerContentHandler)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMsgContentPolicy, Init)
|
||||
#ifdef MOZ_THUNDERBIRD
|
||||
|
@ -853,6 +859,12 @@ static const nsModuleComponentInfo gComponents[] = {
|
|||
NS_MESSENGEROSINTEGRATION_CONTRACTID,
|
||||
nsMessengerOSXIntegrationConstructor,
|
||||
},
|
||||
#endif
|
||||
#if defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_GTK2)
|
||||
{ "Unix OS Integration", NS_MESSENGERUNIXINTEGRATION_CID,
|
||||
NS_MESSENGEROSINTEGRATION_CONTRACTID,
|
||||
nsMessengerUnixIntegrationConstructor,
|
||||
},
|
||||
#endif
|
||||
{ "application/x-message-display content handler",
|
||||
NS_MESSENGERCONTENTHANDLER_CID,
|
||||
|
|
Загрузка…
Ссылка в новой задаче