Bug 835002 - Add back Growl support for TB19/20 and SM 2.16/2.17 r=Callek a=Callek RELEASE_BASE_20130215 SEAMONKEY_2_16b5_BUILD1 SEAMONKEY_2_16b5_RELEASE
authorNomis101
Sun, 27 Jan 2013 03:09:23 +0100
changeset 14418 c32f17244f9a0205dacdcd9f1292f6e09ffa7863
parent 14414 d01a73f9367237f5022da21fb7a44ec935b81e3c
child 14419 dc1b2626b2a277f6e8152fbf77e485d7fcf40765
child 14421 f87927b1eb9594d4acad9ffecf94bdd932a7d659
push idunknown
push userunknown
push dateunknown
reviewersCallek, Callek
bugs835002
Bug 835002 - Add back Growl support for TB19/20 and SM 2.16/2.17 r=Callek a=Callek
mail/locales/en-US/chrome/messenger/messenger.properties
mailnews/base/src/nsMessengerOSXIntegration.mm
suite/locales/en-US/chrome/mailnews/messenger.properties
--- a/mail/locales/en-US/chrome/messenger/messenger.properties
+++ b/mail/locales/en-US/chrome/messenger/messenger.properties
@@ -470,16 +470,19 @@ copyToFolderAgainAccessKey=t
 #LOCALIZATION NOTE %1$S is the e-mail address of the person we will allow remote content for
 alwaysLoadRemoteContentForSender2= Always load remote content from %1$S
 
 #LOCALIZATION NOTE(mdnBarMessageNormal) %1$S is the name of the sender
 mdnBarMessageNormal=%1$S has asked to be notified when you read this message.
 #LOCALIZATION NOTE(mdnBarMessageAddressDiffers) %1$S is the name of the sender, %2$S is the address(es) to send return receipt to
 mdnBarMessageAddressDiffers=%1$S has asked to be notified (on %2$S) when you read this message.
 
+# Strings for growl notifications on Mac OS X
+growlNotification=New Mail
+
 # mailCommands.js
 emptyJunkTitle=Confirm
 emptyJunkMessage=Are you sure you want to permanently delete all messages and subfolders in the Junk folder?
 emptyJunkDontAsk=Don't ask me again.
 emptyTrashTitle=Confirm
 emptyTrashMessage=Are you sure you want to permanently delete all messages and subfolders in the Trash folder?
 emptyTrashDontAsk=Don't ask me again.
 
--- a/mailnews/base/src/nsMessengerOSXIntegration.mm
+++ b/mailnews/base/src/nsMessengerOSXIntegration.mm
@@ -27,16 +27,17 @@
 #include "nsIObserverService.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsIMessengerWindowService.h"
 #include "prprf.h"
 #include "nsIAlertsService.h"
 #include "nsIStringBundle.h"
 #include "nsToolkitCompsCID.h"
+#include "nsINotificationsList.h"
 #include "nsIMsgDatabase.h"
 #include "nsIMsgHdr.h"
 #include "nsIMsgHeaderParser.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIWindowWatcher.h"
 #include "nsMsgLocalCID.h"
 #include "nsIMsgMailNewsUrl.h"
 #include "nsIMsgWindow.h"
@@ -177,19 +178,21 @@ NS_INTERFACE_MAP_BEGIN(nsMessengerOSXInt
    NS_INTERFACE_MAP_ENTRY(nsIObserver)
    NS_INTERFACE_MAP_ENTRY(mozINewMailListener)
 NS_INTERFACE_MAP_END
 
 
 nsresult
 nsMessengerOSXIntegration::Init()
 {
+  // need to register a named Growl notification
   nsresult rv;
   nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
+  observerService->AddObserver(this, "before-growl-registration", false);
   return observerService->AddObserver(this, "mail-startup-done", false);
 }
 
 NS_IMETHODIMP
 nsMessengerOSXIntegration::OnItemPropertyChanged(nsIMsgFolder *, nsIAtom *, char const *, char const *)
 {
   return NS_OK;
 }
@@ -245,16 +248,38 @@ nsMessengerOSXIntegration::Observe(nsISu
     // register with the mail sesson for folder events
     // we care about new count, biff status
     nsCOMPtr<nsIMsgMailSession> mailSession = do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
     return mailSession->AddFolderListener(this, nsIFolderListener::boolPropertyChanged | nsIFolderListener::intPropertyChanged);
   }
 
+  // register named Growl notification for new mail alerts.
+  if (!strcmp(aTopic, "before-growl-registration"))
+  {
+    nsresult rv;
+    nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1", &rv);
+    if (NS_SUCCEEDED(rv))
+      observerService->RemoveObserver(this, "before-growl-registration");
+
+    nsCOMPtr<nsINotificationsList> notifications = do_QueryInterface(aSubject, &rv);
+    if (NS_SUCCEEDED(rv))
+    {
+      nsCOMPtr<nsIStringBundle> bundle;
+      GetStringBundle(getter_AddRefs(bundle));
+      if (bundle)
+      {
+        nsString growlNotification;
+        bundle->GetStringFromName(NS_LITERAL_STRING("growlNotification").get(), getter_Copies(growlNotification));
+        notifications->AddNotification(growlNotification, true);
+      }
+    }
+  }
+
   if (!strcmp(aTopic, kNewChatMessageTopic)) {
     // We don't have to bother about checking if the window is already focused
     // before attempting to bounce the dock icon, as BounceDockIcon is
     // implemented by a getAttention call which won't do anything if the window
     // requesting attention is already focused.
     return BounceDockIcon();
   }
 
@@ -377,24 +402,35 @@ nsMessengerOSXIntegration::ShowAlertMess
   nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   bool showAlert = true;
   prefBranch->GetBoolPref(kBiffShowAlertPref, &showAlert);
 
   if (showAlert)
   {
+    // Use growl if installed
     nsCOMPtr<nsIAlertsService> alertsService (do_GetService(NS_ALERTSERVICE_CONTRACTID, &rv));
-    // If we have an nsIAlertsService implementation, use it:
     if (NS_SUCCEEDED(rv))
     {
-      alertsService->ShowAlertNotification(NS_LITERAL_STRING(kNewMailAlertIcon),
-                                           aAlertTitle, aAlertText, true,
-                                           NS_ConvertASCIItoUTF16(aFolderURI),
-                                           this, EmptyString());
+      nsCOMPtr<nsIStringBundle> bundle;
+      GetStringBundle(getter_AddRefs(bundle));
+      if (bundle)
+      {
+        nsString growlNotification;
+        bundle->GetStringFromName(NS_LITERAL_STRING("growlNotification").get(),
+                                  getter_Copies(growlNotification));
+        rv = alertsService->ShowAlertNotification(NS_LITERAL_STRING(kNewMailAlertIcon),
+                                                  aAlertTitle,
+                                                  aAlertText,
+                                                  true,
+                                                  NS_ConvertASCIItoUTF16(aFolderURI),
+                                                  this,
+                                                  growlNotification);
+      }
     }
 
     BounceDockIcon();
   }
 
   if (!showAlert || NS_FAILED(rv))
     OnAlertFinished();
 
--- a/suite/locales/en-US/chrome/mailnews/messenger.properties
+++ b/suite/locales/en-US/chrome/mailnews/messenger.properties
@@ -385,16 +385,19 @@ confirmPhishingUrl2=%1$S thinks this web
 #LOCALIZATION NOTE %1$S is the e-mail address of the person we will allow remote content for
 alwaysLoadRemoteContentForSender=Click here to always load remote content from %1$S.
 
 #LOCALIZATION NOTE(mdnBarMessageNormal) %1$S is the name of the sender
 mdnBarMessageNormal=%1$S has asked to be notified when you read this message.
 #LOCALIZATION NOTE(mdnBarMessageAddressDiffers) %1$S is the name of the sender, %2$S is the address(es) to send return receipt to
 mdnBarMessageAddressDiffers=%1$S has asked to be notified at %2$S when you read this message.
 
+# Strings for growl notifications on Mac OS X
+growlNotification=New Mail
+
 # mailCommands.js
 emptyJunkTitle=Confirm
 emptyJunkMessage=Are you sure you want to permanently delete all messages and subfolders in the Junk folder?
 emptyJunkDontAsk=Don't ask me again.
 emptyTrashTitle=Confirm
 emptyTrashMessage=Are you sure you want to permanently delete all messages and subfolders in the Trash folder?
 emptyTrashDontAsk=Don't ask me again.