Bug 730211 - Drop Windows 2000 support for c-c. r=dbienvenu
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Mon, 27 Feb 2012 16:31:13 +0900
changeset 10948 96a18db9f16080450cdcbe88b774ba0ba166a5c7
parent 10947 3dd223a8308bc0feb5235cc311d53e1370302486
child 10949 2f700c8359430c234c131930f003a23ee2fe5960
push id463
push userbugzilla@standard8.plus.com
push dateTue, 24 Apr 2012 17:34:51 +0000
treeherdercomm-beta@e53588e8f7b0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbienvenu
bugs730211
Bug 730211 - Drop Windows 2000 support for c-c. r=dbienvenu
configure.in
mailnews/base/src/nsMessengerWinIntegration.cpp
mailnews/base/src/nsMessengerWinIntegration.h
--- a/configure.in
+++ b/configure.in
@@ -796,18 +796,18 @@ EOF
         fi
 
         # Server 2003 is the highest version supported
         MOZ_WINSDK_MAXVER=0x05020000
     fi # !GNU_CC
 
     AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
     AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
-    # Require OS features provided by IE 5.0
-    AC_DEFINE_UNQUOTED(_WIN32_IE,0x0500)
+    # Require OS features provided by IE 6.0 SP2 (XP SP2)
+    AC_DEFINE_UNQUOTED(_WIN32_IE,0x0603)
 
     # If the maximum version supported by this SDK is lower than the target
     # version, error out
     AC_MSG_CHECKING([for Windows SDK being recent enough])
     if $PERL -e "exit(0x$MOZ_WINSDK_TARGETVER > $MOZ_WINSDK_MAXVER)"; then
         AC_MSG_RESULT("yes")
     else
         AC_MSG_RESULT("no")
--- a/mailnews/base/src/nsMessengerWinIntegration.cpp
+++ b/mailnews/base/src/nsMessengerWinIntegration.cpp
@@ -83,21 +83,19 @@
 #include "mozilla/LookAndFeel.h"
 #endif
 #include "mozilla/Services.h"
 
 #include "nsToolkitCompsCID.h"
 #include <stdlib.h>
 #define PROFILE_COMMANDLINE_ARG " -profile "
 
-#define XP_SHSetUnreadMailCounts "SHSetUnreadMailCountW"
-#define XP_SHEnumerateUnreadMailAccounts "SHEnumerateUnreadMailAccountsW"
 #define NOTIFICATIONCLASSNAME "MailBiffNotificationMessageWindow"
 #define UNREADMAILNODEKEY "Software\\Microsoft\\Windows\\CurrentVersion\\UnreadMail\\"
-#define SHELL32_DLL "shell32.dll"
+#define SHELL32_DLL L"shell32.dll"
 #define DOUBLE_QUOTE "\""
 #define MAIL_COMMANDLINE_ARG " -mail"
 #define IDI_MAILBIFF 32576
 #define UNREAD_UPDATE_INTERVAL	(20 * 1000)	// 20 seconds
 #define ALERT_CHROME_URL "chrome://messenger/content/newmailalert.xul"
 #define NEW_MAIL_ALERT_ICON "chrome://messenger/skin/icons/new-mail-alert.png"
 #define SHOW_ALERT_PREF     "mail.biff.show_alert"
 #define SHOW_TRAY_ICON_PREF "mail.biff.show_tray_icon"
@@ -115,21 +113,16 @@
 #ifndef NIIF_NOSOUND
 #define NIIF_NOSOUND    0x00000010
 #endif
 
 #ifndef NIN_BALOONUSERCLICK
 #define NIN_BALLOONUSERCLICK (WM_USER + 5)
 #endif
 
-#if _WIN32_IE < 0x600
-#undef NOTIFYICONDATAW_V2_SIZE
-#define NOTIFYICONDATAW_V2_SIZE sizeof(NOTIFYICONDATAW)
-#endif
-
 using namespace mozilla;
 
 // begin shameless copying from nsNativeAppSupportWin
 HWND hwndForDOMWindow( nsISupports *window )
 {
   nsCOMPtr<nsPIDOMWindow> win( do_QueryInterface(window) );
   if ( !win )
       return 0;
@@ -277,17 +270,16 @@ static nsresult Create()
 
 
 nsMessengerWinIntegration::nsMessengerWinIntegration()
 {
   mDefaultServerAtom = MsgGetAtom("DefaultServer");
   mTotalUnreadMessagesAtom = MsgGetAtom("TotalUnreadMessages");
 
   mUnreadTimerActive = false;
-  mStoreUnreadCounts = false;
 
   mBiffStateAtom = MsgGetAtom("BiffState");
   mBiffIconVisible = false;
   mSuppressBiffIcon = false;
   mAlertInProgress = false;
   mBiffIconInitialized = false;
   NS_NewISupportsArray(getter_AddRefs(mFoldersWithNewMail));
 }
@@ -361,87 +353,60 @@ void nsMessengerWinIntegration::Initiali
   mBiffIconInitialized = true;
 }
 
 nsresult
 nsMessengerWinIntegration::Init()
 {
   nsresult rv;
 
-  // get directory service to build path for shell dll
-  nsCOMPtr<nsIProperties> directoryService =
-    do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv,rv);
-
-  // get path strings needed for unread mail count update
-  nsCOMPtr<nsIFile> systemDir;
-  rv = directoryService->Get(NS_OS_SYSTEM_DIR,
-                             NS_GET_IID(nsIFile),
-                             getter_AddRefs(systemDir));
-  NS_ENSURE_SUCCESS(rv,rv);
+  // Get shell32.dll handle
+  HMODULE hModule = ::GetModuleHandleW(SHELL32_DLL);
 
-  // get path to shell dll.
-  nsCAutoString shellFile;
-  rv = systemDir->GetNativePath(shellFile);
-  NS_ENSURE_SUCCESS(rv,rv);
-
-  shellFile.AppendLiteral("\\" SHELL32_DLL);
-
-  // load shell dll. If no such dll found, return
-  HMODULE hModule = ::LoadLibrary(shellFile.get());
-  if (!hModule)
-    return NS_OK;
-
-  // get process addresses for the unread mail count functions
   if (hModule) {
-    mSHSetUnreadMailCount = (fnSHSetUnreadMailCount)GetProcAddress(hModule, XP_SHSetUnreadMailCounts);
-    mSHEnumerateUnreadMailAccounts = (fnSHEnumerateUnreadMailAccounts)GetProcAddress(hModule, XP_SHEnumerateUnreadMailAccounts);
+    // SHQueryUserNotificationState is available from Vista
     mSHQueryUserNotificationState = (fnSHQueryUserNotificationState)GetProcAddress(hModule, "SHQueryUserNotificationState");
   }
 
-  // if failed to get either of the process addresses, this is not XP platform
-  // so we aren't storing unread counts
-  if (mSHSetUnreadMailCount && mSHEnumerateUnreadMailAccounts)
-    mStoreUnreadCounts = true;
-
   nsCOMPtr <nsIMsgAccountManager> accountManager =
     do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv,rv);
 
   // because we care if the default server changes
   rv = accountManager->AddRootFolderListener(this);
   NS_ENSURE_SUCCESS(rv,rv);
 
   nsCOMPtr<nsIMsgMailSession> mailSession = do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv,rv);
 
   // because we care if the unread total count changes
   rv = mailSession->AddFolderListener(this, nsIFolderListener::boolPropertyChanged | nsIFolderListener::intPropertyChanged);
   NS_ENSURE_SUCCESS(rv,rv);
 
-  if (mStoreUnreadCounts)
-  {
-    // get current profile path for the commandliner
-    nsCOMPtr<nsIFile> profilePath;
-    rv = directoryService->Get(NS_APP_USER_PROFILE_50_DIR,
-                               NS_GET_IID(nsIFile),
-                               getter_AddRefs(profilePath));
-    NS_ENSURE_SUCCESS(rv,rv);
+  // get current profile path for the commandliner
+  nsCOMPtr<nsIProperties> directoryService =
+    do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
+  NS_ENSURE_SUCCESS(rv,rv);
+
+  nsCOMPtr<nsIFile> profilePath;
+  rv = directoryService->Get(NS_APP_USER_PROFILE_50_DIR,
+                             NS_GET_IID(nsIFile),
+                             getter_AddRefs(profilePath));
+  NS_ENSURE_SUCCESS(rv,rv);
 
-    rv = profilePath->GetPath(mProfilePath);
-    NS_ENSURE_SUCCESS(rv, rv);
+  rv = profilePath->GetPath(mProfilePath);
+  NS_ENSURE_SUCCESS(rv, rv);
 
-    // get application path
-    WCHAR appPath[_MAX_PATH] = {0};
-    ::GetModuleFileNameW(nsnull, appPath, sizeof(appPath));
-    mAppName.Assign((PRUnichar *)appPath);
+  // get application path
+  WCHAR appPath[_MAX_PATH] = {0};
+  ::GetModuleFileNameW(nsnull, appPath, sizeof(appPath));
+  mAppName.Assign((PRUnichar *)appPath);
 
-    rv = ResetCurrent();
-    NS_ENSURE_SUCCESS(rv,rv);
-  }
+  rv = ResetCurrent();
+  NS_ENSURE_SUCCESS(rv,rv);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsMessengerWinIntegration::OnItemPropertyChanged(nsIMsgFolder *, nsIAtom *, char const *, char const *)
 {
   return NS_OK;
@@ -912,18 +877,16 @@ nsMessengerWinIntegration::OnItemIntProp
       if (mBiffIconVisible)
       {
         mBiffIconVisible = false;
         GenericShellNotify(NIM_DELETE);
       }
     }
   } // if the biff property changed
 
-  if (!mStoreUnreadCounts) return NS_OK; // don't do anything here if we aren't storing unread counts...
-
   if (aProperty == mTotalUnreadMessagesAtom) {
     nsCString itemURI;
     nsresult rv;
     rv = aItem->GetURI(itemURI);
     NS_ENSURE_SUCCESS(rv,rv);
 
     if (mInboxURI.Equals(itemURI))
       mCurrentUnreadCount = aNewValue;
@@ -957,34 +920,32 @@ nsMessengerWinIntegration::OnUnreadCount
   winIntegration->mUnreadTimerActive = false;
   nsresult rv = winIntegration->UpdateUnreadCount();
   NS_ASSERTION(NS_SUCCEEDED(rv), "updating unread count failed");
 }
 
 nsresult
 nsMessengerWinIntegration::RemoveCurrentFromRegistry()
 {
-  if (!mStoreUnreadCounts) return NS_OK; // don't do anything here if we aren't storing unread counts...
-
   // If Windows XP, open the registry and get rid of old account registry entries
   // If there is a email prefix, get it and use it to build the registry key.
   // Otherwise, just the email address will be the registry key.
   nsAutoString currentUnreadMailCountKey;
   if (!mEmailPrefix.IsEmpty()) {
     currentUnreadMailCountKey.Assign(mEmailPrefix);
     currentUnreadMailCountKey.Append(NS_ConvertASCIItoUTF16(mEmail));
   }
   else
     CopyASCIItoUTF16(mEmail, currentUnreadMailCountKey);
 
   WCHAR registryUnreadMailCountKey[_MAX_PATH] = {0};
   // Enumerate through registry entries to delete the key matching
   // currentUnreadMailCountKey
   int index = 0;
-  while (SUCCEEDED(mSHEnumerateUnreadMailAccounts(HKEY_CURRENT_USER,
+  while (SUCCEEDED(SHEnumerateUnreadMailAccountsW(HKEY_CURRENT_USER,
                                                   index,
                                                   registryUnreadMailCountKey,
                                                   sizeof(registryUnreadMailCountKey))))
   {
     if (wcscmp(registryUnreadMailCountKey, currentUnreadMailCountKey.get())==0) {
       nsAutoString deleteKey;
       deleteKey.Assign(NS_LITERAL_STRING(UNREADMAILNODEKEY).get());
       deleteKey.Append(currentUnreadMailCountKey.get());
@@ -1004,18 +965,16 @@ nsMessengerWinIntegration::RemoveCurrent
     }
   }
   return NS_OK;
 }
 
 nsresult
 nsMessengerWinIntegration::UpdateRegistryWithCurrent()
 {
-  if (!mStoreUnreadCounts) return NS_OK; // don't do anything here if we aren't storing unread counts...
-
   if (mInboxURI.IsEmpty() || mEmail.IsEmpty())
     return NS_OK;
 
   // only update the registry if the count has changed
   // and if the unread count is valid
   if ((mCurrentUnreadCount < 0) || (mCurrentUnreadCount == mLastUnreadCountWrittenToRegistry))
     return NS_OK;
 
@@ -1041,32 +1000,31 @@ nsMessengerWinIntegration::UpdateRegistr
     if (!mEmailPrefix.IsEmpty()) {
       pBuffer.Assign(mEmailPrefix);
       pBuffer.Append(NS_ConvertASCIItoUTF16(mEmail));
     }
     else
       CopyASCIItoUTF16(mEmail, pBuffer);
 
     // Write the info into the registry
-    HRESULT hr = mSHSetUnreadMailCount(pBuffer.get(),
+    HRESULT hr = SHSetUnreadMailCountW(pBuffer.get(),
                                        mCurrentUnreadCount,
                                        commandLinerForAppLaunch.get());
   }
 
   // do this last
   mLastUnreadCountWrittenToRegistry = mCurrentUnreadCount;
 
   return NS_OK;
 }
 
 nsresult
 nsMessengerWinIntegration::SetupInbox()
 {
   nsresult rv;
-  if (!mStoreUnreadCounts) return NS_OK; // don't do anything here if we aren't storing unread counts...
 
   // get default account
   nsCOMPtr <nsIMsgAccountManager> accountManager =
     do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv,rv);
 
   nsCOMPtr <nsIMsgAccount> account;
   rv = accountManager->GetDefaultAccount(getter_AddRefs(account));
@@ -1134,30 +1092,28 @@ nsMessengerWinIntegration::SetupInbox()
 
   return NS_OK;
 }
 
 nsresult
 nsMessengerWinIntegration::UpdateUnreadCount()
 {
   nsresult rv;
-  if (!mStoreUnreadCounts) return NS_OK; // don't do anything here if we aren't storing unread counts...
 
   if (mDefaultAccountMightHaveAnInbox && mInboxURI.IsEmpty()) {
     rv = SetupInbox();
     NS_ENSURE_SUCCESS(rv,rv);
   }
 
   return UpdateRegistryWithCurrent();
 }
 
 nsresult
 nsMessengerWinIntegration::SetupUnreadCountUpdateTimer()
 {
-  if (!mStoreUnreadCounts) return NS_OK; // don't do anything here if we aren't storing unread counts...
   mUnreadTimerActive = true;
   if (mUnreadCountUpdateTimer)
     mUnreadCountUpdateTimer->Cancel();
   else
     mUnreadCountUpdateTimer = do_CreateInstance("@mozilla.org/timer;1");
 
   mUnreadCountUpdateTimer->InitWithFuncCallback(OnUnreadCountUpdateTimer,
     (void *)this, UNREAD_UPDATE_INTERVAL, nsITimer::TYPE_ONE_SHOT);
--- a/mailnews/base/src/nsMessengerWinIntegration.h
+++ b/mailnews/base/src/nsMessengerWinIntegration.h
@@ -59,21 +59,19 @@ typedef enum tagMOZ_QUERY_USER_NOTIFICAT
     QUNS_NOT_PRESENT = 1,
     QUNS_BUSY = 2,
     QUNS_RUNNING_D3D_FULL_SCREEN = 3,
     QUNS_PRESENTATION_MODE = 4,
     QUNS_ACCEPTS_NOTIFICATIONS = 5,
     QUNS_QUIET_TIME = 6
 } MOZ_QUERY_USER_NOTIFICATION_STATE;
 
-// this function is exported by shell32.dll version 5.60 or later (Windows XP or greater)
+// this function is exported by shell32.dll on Windows Vista or later
 extern "C"
 {
-typedef HRESULT (__stdcall *fnSHSetUnreadMailCount)(LPCWSTR pszMailAddress, DWORD dwCount, LPCWSTR pszShellExecuteCommand);
-typedef HRESULT (__stdcall *fnSHEnumerateUnreadMailAccounts)(HKEY hKeyUser, DWORD dwIndex, LPCWSTR pszMailAddress, int cchMailAddress);
 // Vista or later
 typedef HRESULT (__stdcall *fnSHQueryUserNotificationState)(MOZ_QUERY_USER_NOTIFICATION_STATE *pquns);
 }
 
 #define NS_MESSENGERWININTEGRATION_CID \
   {0xf62f3d3a, 0x1dd1, 0x11b2, \
     {0xa5, 0x16, 0xef, 0xad, 0xb1, 0x31, 0x61, 0x5c}}
 
@@ -110,18 +108,16 @@ private:
 
   nsresult GetFirstFolderWithNewMail(nsACString& aFolderURI);
 
   nsresult GetStringBundle(nsIStringBundle **aBundle);
   nsCOMPtr<nsISupportsArray> mFoldersWithNewMail;  // keep track of all the root folders with pending new mail
   nsCOMPtr<nsIAtom> mBiffStateAtom;
   PRUint32 mCurrentBiffState;
 
-  bool mStoreUnreadCounts;   // for windows XP, we do a lot of work to store the last unread count for the inbox
-                                     // this flag is set to true when we are doing that
   bool mBiffIconVisible;
   bool mBiffIconInitialized;
   bool mSuppressBiffIcon;
   bool mAlertInProgress;
   
   // "might" because we don't know until we check 
   // what type of server is associated with the default account
   bool            mDefaultAccountMightHaveAnInbox;
@@ -137,18 +133,16 @@ private:
   nsresult SetupUnreadCountUpdateTimer();
   static void OnUnreadCountUpdateTimer(nsITimer *timer, void *osIntegration);
   nsresult UpdateUnreadCount();
 
   nsCOMPtr <nsIAtom> mDefaultServerAtom;
   nsCOMPtr <nsIAtom> mTotalUnreadMessagesAtom;
   nsCOMPtr <nsITimer> mUnreadCountUpdateTimer;
 
-  fnSHSetUnreadMailCount mSHSetUnreadMailCount;
-  fnSHEnumerateUnreadMailAccounts mSHEnumerateUnreadMailAccounts;
   fnSHQueryUserNotificationState mSHQueryUserNotificationState;
 
   nsCString mInboxURI;
   nsCString mEmail;
 
   nsString  mAppName;
   nsString  mEmailPrefix;