Part 3 of
bug 472093 -- fix build system to use NTDDI_VERSION instead of random checks -- add MOZ_NTDDI_* defines, switch code over to use these defines.
r=ted for build config parts, r=jmathies for app association and download manager changes, r+sr=bz for helper app service, r=vlad + sr=ted for stock icons.
--- a/browser/components/shell/src/nsWindowsShellService.cpp
+++ b/browser/components/shell/src/nsWindowsShellService.cpp
@@ -211,17 +211,17 @@ static SETTING gSettings[] = {
{ MAKE_KEY_NAME1("HTTP", SOP), "", VAL_OPEN },
{ MAKE_KEY_NAME1("HTTPS", DI), "", VAL_FILE_ICON },
{ MAKE_KEY_NAME1("HTTPS", SOP), "", VAL_OPEN }
};
PRBool
nsWindowsShellService::IsDefaultBrowserVista(PRBool* aIsDefaultBrowser)
{
-#if !defined(MOZ_DISABLE_VISTA_SDK_REQUIREMENTS)
+#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
IApplicationAssociationRegistration* pAAR;
HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration,
NULL,
CLSCTX_INPROC,
IID_IApplicationAssociationRegistration,
(void**)&pAAR);
--- a/configure.in
+++ b/configure.in
@@ -727,16 +727,20 @@ EOF
if $PERL -e "exit(0x$MOZ_WINSDK_TARGETVER > $MOZ_WINSDK_MAXVER)"; then
AC_MSG_RESULT("yes")
else
AC_MSG_RESULT("no")
AC_MSG_ERROR([You are targeting Windows version 0x$MOZ_WINSDK_TARGETVER, but your SDK only supports up to version $MOZ_WINSDK_MAXVER. Install and use an updated SDK, or target a lower version using --with-windows-version. See https://developer.mozilla.org/En/Windows_SDK_versions for more details on fixing this.])
fi
AC_DEFINE_UNQUOTED(MOZ_WINSDK_TARGETVER,0x$MOZ_WINSDK_TARGETVER)
+ # Definitions matching sdkddkver.h
+ AC_DEFINE_UNQUOTED(MOZ_NTDDI_WS03, 0x05020000)
+ AC_DEFINE_UNQUOTED(MOZ_NTDDI_LONGHORN, 0x06000000)
+ AC_DEFINE_UNQUOTED(MOZ_NTDDI_WIN7, 0x06010000)
;;
esac
dnl Test breaks icc on OS/2 && MSVC
if test "$CC" != "icc" -a -z "$_WIN32_MSVC"; then
AC_PROG_CC_C_O
if grep "NO_MINUS_C_MINUS_O 1" ./confdefs.h >/dev/null; then
USING_HCC=1
--- a/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp
+++ b/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp
@@ -54,17 +54,17 @@
#include "nsNetUtil.h"
#include "nsInt64.h"
#include "nsIFile.h"
#include "nsIFileURL.h"
#include "nsIMIMEService.h"
#include "nsCExternalHandlerService.h"
#include "nsDirectoryServiceDefs.h"
-#ifndef MOZ_DISABLE_VISTA_SDK_REQUIREMENTS
+#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
#define _WIN32_WINNT 0x0600
#endif
// we need windows.h to read out registry information...
#include <windows.h>
@@ -84,17 +84,17 @@ struct ICONENTRY {
PRUint8 ieColors;
PRUint8 ieReserved;
PRUint16 iePlanes;
PRUint16 ieBitCount;
PRUint32 ieSizeImage;
PRUint32 ieFileOffset;
};
-#ifndef MOZ_DISABLE_VISTA_SDK_REQUIREMENTS
+#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
typedef HRESULT (WINAPI*SHGetStockIconInfoPtr) (SHSTOCKICONID siid, UINT uFlags, SHSTOCKICONINFO *psii);
// Match stock icons with names
static SHSTOCKICONID GetStockIconIDForName(const nsACString &aStockName)
{
// UAC shield icon
if (aStockName == NS_LITERAL_CSTRING("uac-shield"))
return SIID_SHIELD;
@@ -388,17 +388,17 @@ nsresult nsIconChannel::GetHIconFromFile
*hIcon = sfi.hIcon;
else
rv = NS_ERROR_NOT_AVAILABLE;
return rv;
#endif
}
-#ifndef MOZ_DISABLE_VISTA_SDK_REQUIREMENTS
+#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
nsresult nsIconChannel::GetStockHIcon(nsIMozIconURI *aIconURI, HICON *hIcon)
{
nsresult rv = NS_OK;
// We can only do this on Vista or above
HMODULE hShellDLL = ::LoadLibraryW(L"shell32.dll");
SHGetStockIconInfoPtr pSHGetStockIconInfo =
(SHGetStockIconInfoPtr) ::GetProcAddress(hShellDLL, "SHGetStockIconInfo");
@@ -442,17 +442,17 @@ nsresult nsIconChannel::MakeInputStream(
{
// Check whether the icon requested's a file icon or a stock icon
nsresult rv = NS_ERROR_NOT_AVAILABLE;
// GetDIBits does not exist on windows mobile.
#ifndef WINCE
HICON hIcon = NULL;
-#ifndef MOZ_DISABLE_VISTA_SDK_REQUIREMENTS
+#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
nsCOMPtr<nsIMozIconURI> iconURI(do_QueryInterface(mUrl, &rv));
NS_ENSURE_SUCCESS(rv, rv);
nsCAutoString stockIcon;
iconURI->GetStockIcon(stockIcon);
if (!stockIcon.IsEmpty())
rv = GetStockHIcon(iconURI, &hIcon);
else
--- a/modules/libpr0n/decoders/icon/win/nsIconChannel.h
+++ b/modules/libpr0n/decoders/icon/win/nsIconChannel.h
@@ -80,15 +80,15 @@ protected:
nsCOMPtr<nsIInputStreamPump> mPump;
nsCOMPtr<nsIStreamListener> mListener;
nsresult ExtractIconInfoFromUrl(nsIFile ** aLocalFile, PRUint32 * aDesiredImageSize, nsCString &aContentType, nsCString &aFileExtension);
nsresult GetHIconFromFile(HICON *hIcon);
nsresult MakeInputStream(nsIInputStream** _retval, PRBool nonBlocking);
// Functions specific to Vista and above
-#ifndef MOZ_DISABLE_VISTA_SDK_REQUIREMENTS
+#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
protected:
nsresult GetStockHIcon(nsIMozIconURI *aIconURI, HICON *hIcon);
#endif
};
#endif /* nsIconChannel_h___ */
--- a/toolkit/components/downloads/src/Makefile.in
+++ b/toolkit/components/downloads/src/Makefile.in
@@ -70,23 +70,20 @@ REQUIRES = xpcom \
toolkitcomps \
places \
$(NULL)
CPPSRCS = \
nsDownloadManager.cpp \
$(NULL)
-ifndef MOZ_DISABLE_VISTA_SDK_REQUIREMENTS
ifndef GNU_CXX
ifeq ($(OS_ARCH),WINNT)
CPPSRCS += nsDownloadScanner.cpp
REQUIRES += xulapp
-DEFINES += -DDOWNLOAD_SCANNER
-endif
endif
endif
ifndef MOZ_SUITE
# XXX - Until Suite builds off XULRunner we can't guarantee our implementation
# of nsIDownloadManagerUI overrides toolkit's.
EXTRA_COMPONENTS = \
nsDownloadManagerUI.js \
--- a/toolkit/components/downloads/src/nsDownloadManager.h
+++ b/toolkit/components/downloads/src/nsDownloadManager.h
@@ -39,16 +39,20 @@
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef downloadmanager___h___
#define downloadmanager___h___
+#if defined(XP_WIN) && (MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN)
+#define DOWNLOAD_SCANNER
+#endif
+
#include "nsIDownload.h"
#include "nsIDownloadManager.h"
#include "nsIDownloadProgressListener.h"
#include "nsILocalFile.h"
#include "nsIMIMEInfo.h"
#include "nsINavHistoryService.h"
#include "nsIObserver.h"
#include "nsIObserverService.h"
--- a/toolkit/components/downloads/src/nsDownloadScanner.cpp
+++ b/toolkit/components/downloads/src/nsDownloadScanner.cpp
@@ -31,17 +31,19 @@
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
-
+
+#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
+
#include "nsDownloadScanner.h"
#include <comcat.h>
#include <process.h>
#include "nsDownloadManager.h"
#include "nsIXULAppInfo.h"
#include "nsXULAppAPI.h"
#include "nsIPrefService.h"
#include "nsNetUtil.h"
@@ -939,8 +941,10 @@ nsDownloadScannerWatchdog::WatchdogThrea
// don't need to release the scan
NS_RELEASE(releaser);
}
}
}
_endthreadex(0);
return 0;
}
+
+#endif // MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
--- a/toolkit/components/downloads/src/nsDownloadScanner.h
+++ b/toolkit/components/downloads/src/nsDownloadScanner.h
@@ -1,10 +1,12 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: se cin sw=2 ts=2 et : */
+#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
+
#ifndef nsDownloadScanner_h_
#define nsDownloadScanner_h_
#ifdef WIN32_LEAN_AND_MEAN
#undef WIN32_LEAN_AND_MEAN
#endif
#define INITGUID
#include <windows.h>
@@ -119,8 +121,10 @@ private:
PRBool DoScanOAV();
friend unsigned int __stdcall nsDownloadScanner::ScannerThreadFunction(void *);
};
// Used to give access to Scan
friend class nsDownloadScannerWatchdog;
};
#endif
+
+#endif // MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
--- a/uriloader/exthandler/win/nsOSHelperAppService.cpp
+++ b/uriloader/exthandler/win/nsOSHelperAppService.cpp
@@ -63,30 +63,30 @@
// helper methods: forward declarations...
static nsresult GetExtensionFrom4xRegistryInfo(const nsACString& aMimeType,
nsString& aFileExtension);
static nsresult GetExtensionFromWindowsMimeDatabase(const nsACString& aMimeType,
nsString& aFileExtension);
nsOSHelperAppService::nsOSHelperAppService() :
nsExternalHelperAppService()
-#if !defined(MOZ_DISABLE_VISTA_SDK_REQUIREMENTS)
+#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
, mAppAssoc(nsnull)
#endif
{
-#if !defined(MOZ_DISABLE_VISTA_SDK_REQUIREMENTS)
+#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
CoInitialize(NULL);
CoCreateInstance(CLSID_ApplicationAssociationRegistration, NULL, CLSCTX_INPROC,
IID_IApplicationAssociationRegistration, (void**)&mAppAssoc);
#endif
}
nsOSHelperAppService::~nsOSHelperAppService()
{
-#if !defined(MOZ_DISABLE_VISTA_SDK_REQUIREMENTS)
+#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
if (mAppAssoc)
mAppAssoc->Release();
mAppAssoc = nsnull;
CoUninitialize();
#endif
}
// The windows registry provides a mime database key which lists a set of mime types and corresponding "Extension" values.
@@ -154,17 +154,17 @@ static nsresult GetExtensionFrom4xRegist
}
nsresult nsOSHelperAppService::OSProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists)
{
// look up the protocol scheme in the windows registry....if we find a match then we have a handler for it...
*aHandlerExists = PR_FALSE;
if (aProtocolScheme && *aProtocolScheme)
{
-#if !defined(MOZ_DISABLE_VISTA_SDK_REQUIREMENTS)
+#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
// Vista: use new application association interface
if (mAppAssoc) {
PRUnichar * pResult = nsnull;
NS_ConvertASCIItoUTF16 scheme(aProtocolScheme);
// We are responsible for freeing returned strings.
HRESULT hr = mAppAssoc->QueryCurrentDefault(scheme.get(),
AT_URLPROTOCOL, AL_EFFECTIVE,
&pResult);
@@ -198,17 +198,17 @@ NS_IMETHODIMP nsOSHelperAppService::GetA
{
nsCOMPtr<nsIWindowsRegKey> regKey =
do_CreateInstance("@mozilla.org/windows-registry-key;1");
if (!regKey)
return NS_ERROR_NOT_AVAILABLE;
NS_ConvertASCIItoUTF16 buf(aScheme);
-#if !defined(MOZ_DISABLE_VISTA_SDK_REQUIREMENTS)
+#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
// Vista: use new application association interface
if (mAppAssoc) {
PRUnichar * pResult = nsnull;
// We are responsible for freeing returned strings.
HRESULT hr = mAppAssoc->QueryCurrentDefault(buf.get(),
AT_URLPROTOCOL, AL_EFFECTIVE,
&pResult);
if (SUCCEEDED(hr)) {
@@ -550,17 +550,17 @@ already_AddRefed<nsMIMEInfoWin> nsOSHelp
// don't append the '.'
mimeInfo->AppendExtension(NS_ConvertUTF16toUTF8(Substring(fileExtToUse, 1)));
mimeInfo->SetPreferredAction(nsIMIMEInfo::useSystemDefault);
nsAutoString appInfo;
PRBool found;
-#if !defined(MOZ_DISABLE_VISTA_SDK_REQUIREMENTS)
+#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
// Retrieve the default application for this extension
if (mAppAssoc) {
// Vista: use the new application association COM interfaces
// for resolving helpers.
nsString assocType(fileExtToUse);
PRUnichar * pResult = nsnull;
HRESULT hr = mAppAssoc->QueryCurrentDefault(assocType.get(),
AT_FILEEXTENSION, AL_EFFECTIVE,
--- a/uriloader/exthandler/win/nsOSHelperAppService.h
+++ b/uriloader/exthandler/win/nsOSHelperAppService.h
@@ -88,14 +88,14 @@ protected:
already_AddRefed<nsMIMEInfoWin> GetByExtension(const nsAFlatString& aFileExt, const char *aTypeHint = nsnull);
nsresult FindOSMimeInfoForType(const char * aMimeContentType, nsIURI * aURI, char ** aFileExtension, nsIMIMEInfo ** aMIMEInfo);
static nsresult GetMIMEInfoFromRegistry(const nsAFlatString& fileType, nsIMIMEInfo *pInfo);
/// Looks up the type for the extension aExt and compares it to aType
static PRBool typeFromExtEquals(const PRUnichar* aExt, const char *aType);
private:
-#if !defined(MOZ_DISABLE_VISTA_SDK_REQUIREMENTS)
+#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
IApplicationAssociationRegistration* mAppAssoc;
#endif
};
#endif // nsOSHelperAppService_h__