--- a/accessible/src/msaa/nsAccessNodeWrap.cpp
+++ b/accessible/src/msaa/nsAccessNodeWrap.cpp
@@ -571,17 +571,17 @@ void nsAccessNodeWrap::InitAccessibility
}
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefBranch) {
prefBranch->GetBoolPref("accessibility.disableenumvariant", &gIsEnumVariantSupportDisabled);
}
if (!gmUserLib) {
- gmUserLib =::LoadLibrary("USER32.DLL");
+ gmUserLib =::LoadLibraryW(L"USER32.DLL");
}
if (gmUserLib) {
if (!gmNotifyWinEvent)
gmNotifyWinEvent = (LPFNNOTIFYWINEVENT)GetProcAddress(gmUserLib,"NotifyWinEvent");
if (!gmGetGUIThreadInfo)
gmGetGUIThreadInfo = (LPFNGETGUITHREADINFO)GetProcAddress(gmUserLib,"GetGUIThreadInfo");
}
--- a/accessible/src/msaa/nsAccessibleWrap.cpp
+++ b/accessible/src/msaa/nsAccessibleWrap.cpp
@@ -151,17 +151,17 @@ STDMETHODIMP nsAccessibleWrap::QueryInte
STDMETHODIMP nsAccessibleWrap::AccessibleObjectFromWindow(HWND hwnd,
DWORD dwObjectID,
REFIID riid,
void **ppvObject)
{
// open the dll dynamically
if (!gmAccLib)
- gmAccLib =::LoadLibrary("OLEACC.DLL");
+ gmAccLib =::LoadLibraryW(L"OLEACC.DLL");
if (gmAccLib) {
if (!gmAccessibleObjectFromWindow)
gmAccessibleObjectFromWindow = (LPFNACCESSIBLEOBJECTFROMWINDOW)GetProcAddress(gmAccLib,"AccessibleObjectFromWindow");
if (gmAccessibleObjectFromWindow)
return gmAccessibleObjectFromWindow(hwnd, dwObjectID, riid, ppvObject);
}
--- a/browser/app/nsBrowserApp.cpp
+++ b/browser/app/nsBrowserApp.cpp
@@ -59,21 +59,19 @@
#endif
static void Output(const char *fmt, ... )
{
va_list ap;
va_start(ap, fmt);
#if defined(XP_WIN) && !MOZ_WINCONSOLE
- char msg[2048];
-
- _vsnprintf(msg, sizeof(msg), fmt, ap);
-
- MessageBox(NULL, msg, "XULRunner", MB_OK | MB_ICONERROR);
+ PRUnichar msg[2048];
+ _vsnwprintf(msg, sizeof(msg), NS_ConvertUTF8toUTF16(fmt).get(), ap);
+ MessageBoxW(NULL, msg, L"XULRunner", MB_OK | MB_ICONERROR);
#else
vfprintf(stderr, fmt, ap);
#endif
va_end(ap);
}
/**
--- a/browser/components/migration/src/nsIEProfileMigrator.cpp
+++ b/browser/components/migration/src/nsIEProfileMigrator.cpp
@@ -862,17 +862,17 @@ static GUID IEPStoreSiteAuthGUID = { 0x5
nsresult
nsIEProfileMigrator::CopyPasswords(PRBool aReplace)
{
HRESULT hr;
nsresult rv;
nsVoidArray signonsFound;
- HMODULE pstoreDLL = ::LoadLibrary("pstorec.dll");
+ HMODULE pstoreDLL = ::LoadLibraryW(L"pstorec.dll");
if (!pstoreDLL) {
// XXXben TODO
// Need to figure out what to do here on Windows 98 etc... it may be that the key is universal read
// and we can just blunder into the registry and use CryptUnprotect to get the data out.
return NS_ERROR_FAILURE;
}
PStoreCreateInstancePtr PStoreCreateInstance = (PStoreCreateInstancePtr)::GetProcAddress(pstoreDLL, "PStoreCreateInstance");
@@ -1172,17 +1172,17 @@ nsIEProfileMigrator::GetUserNameAndPass(
//
// "Quite Easily Done". ;-)
//
nsresult
nsIEProfileMigrator::CopyFormData(PRBool aReplace)
{
HRESULT hr;
- HMODULE pstoreDLL = ::LoadLibrary("pstorec.dll");
+ HMODULE pstoreDLL = ::LoadLibraryW(L"pstorec.dll");
if (!pstoreDLL) {
// XXXben TODO
// Need to figure out what to do here on Windows 98 etc... it may be that the key is universal read
// and we can just blunder into the registry and use CryptUnprotect to get the data out.
return NS_ERROR_FAILURE;
}
PStoreCreateInstancePtr PStoreCreateInstance = (PStoreCreateInstancePtr)::GetProcAddress(pstoreDLL, "PStoreCreateInstance");
@@ -1405,30 +1405,29 @@ nsIEProfileMigrator::CopySmartKeywords(P
return NS_OK;
}
void
nsIEProfileMigrator::ResolveShortcut(const nsString &aFileName, char** aOutURL)
{
HRESULT result;
- IUniformResourceLocator* urlLink = nsnull;
+ IUniformResourceLocatorW* urlLink = nsnull;
result = ::CoCreateInstance(CLSID_InternetShortcut, NULL, CLSCTX_INPROC_SERVER,
- IID_IUniformResourceLocator, (void**)&urlLink);
+ IID_IUniformResourceLocatorW, (void**)&urlLink);
if (SUCCEEDED(result) && urlLink) {
IPersistFile* urlFile = nsnull;
result = urlLink->QueryInterface(IID_IPersistFile, (void**)&urlFile);
if (SUCCEEDED(result) && urlFile) {
result = urlFile->Load(aFileName.get(), STGM_READ);
if (SUCCEEDED(result) ) {
- LPSTR lpTemp = nsnull;
+ LPWSTR lpTemp = nsnull;
result = urlLink->GetURL(&lpTemp);
if (SUCCEEDED(result) && lpTemp) {
- *aOutURL = PL_strdup(lpTemp);
-
+ *aOutURL = *aOutURL = (char*)ToNewUTF8String(nsDependentString(lpTemp));
// free the string that GetURL alloc'd
::CoTaskMemFree(lpTemp);
}
}
urlFile->Release();
}
urlLink->Release();
}
--- a/browser/components/shell/src/nsWindowsShellService.cpp
+++ b/browser/components/shell/src/nsWindowsShellService.cpp
@@ -391,30 +391,30 @@ nsWindowsShellService::SetDefaultBrowser
NS_ENSURE_SUCCESS(rv, rv);
rv = appHelper->AppendNative(NS_LITERAL_CSTRING("uninstall"));
NS_ENSURE_SUCCESS(rv, rv);
rv = appHelper->AppendNative(NS_LITERAL_CSTRING("helper.exe"));
NS_ENSURE_SUCCESS(rv, rv);
- nsCAutoString appHelperPath;
- rv = appHelper->GetNativePath(appHelperPath);
+ nsAutoString appHelperPath;
+ rv = appHelper->GetPath(appHelperPath);
NS_ENSURE_SUCCESS(rv, rv);
if (aForAllUsers) {
appHelperPath.AppendLiteral(" /SetAsDefaultAppGlobal");
} else {
appHelperPath.AppendLiteral(" /SetAsDefaultAppUser");
}
- STARTUPINFO si = {sizeof(si), 0};
+ STARTUPINFOW si = {sizeof(si), 0};
PROCESS_INFORMATION pi = {0};
- BOOL ok = CreateProcess(NULL, (LPSTR)appHelperPath.get(), NULL, NULL,
+ BOOL ok = CreateProcessW(NULL, (LPWSTR)appHelperPath.get(), NULL, NULL,
FALSE, 0, NULL, NULL, &si, &pi);
if (!ok)
return NS_ERROR_FAILURE;
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
--- a/db/mork/src/morkFile.cpp
+++ b/db/mork/src/morkFile.cpp
@@ -924,24 +924,14 @@ morkStdioFile::Steal(nsIMdbEnv* ev, nsIM
}
#if defined(MORK_WIN)
void mork_fileflush(FILE * file)
{
fflush(file);
-#ifndef WINCE
- OSVERSIONINFOA vi = { sizeof(OSVERSIONINFOA) };
- if ((GetVersionExA(&vi) && vi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS))
- {
- // Win9x/ME
- int fd = fileno(file);
- HANDLE fh = (HANDLE)_get_osfhandle(fd);
- FlushFileBuffers(fh);
- }
-#endif
}
#endif /*MORK_WIN*/
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
--- a/embedding/browser/activex/src/plugin/LegacyPlugin.cpp
+++ b/embedding/browser/activex/src/plugin/LegacyPlugin.cpp
@@ -298,18 +298,17 @@ ShowError(MozAxPluginErrors errorCode, c
}
break;
case MozAxErrorCouldNotCreateControl:
{
USES_CONVERSION;
LPOLESTR szClsid;
StringFromCLSID(clsid, &szClsid);
_sntprintf(szBuffer, kBufSize - 1,
- _T("Could not create the control %s. Check that it has been installed on your computer "
- "and that this page correctly references it."), OLE2T(szClsid));
+ _T("Could not create the control %s. Check that it has been installed on your computer and that this page correctly references it."), OLE2T(szClsid));
CoTaskMemFree(szClsid);
szMsg = szBuffer;
}
break;
}
szBuffer[kBufSize - 1] = TCHAR('\0');
if (szMsg)
MessageBox(NULL, szMsg, _T("ActiveX Error"), MB_OK | MB_ICONWARNING);
--- a/embedding/browser/activex/src/plugin/XPCDocument.cpp
+++ b/embedding/browser/activex/src/plugin/XPCDocument.cpp
@@ -1910,17 +1910,17 @@ END_COM_MAP()
if (doc)
{
nsIURI *baseURI = doc->GetBaseURI();
nsCAutoString spec;
if (baseURI &&
NS_SUCCEEDED(baseURI->GetSpec(spec)))
{
USES_CONVERSION;
- if (FAILED(CreateURLMoniker(NULL, T2CW(spec.get()), &baseURLMoniker)))
+ if (FAILED(CreateURLMoniker(NULL, A2CW(spec.get()), &baseURLMoniker)))
return E_UNEXPECTED;
}
}
// Make the moniker
HRESULT hr = CreateURLMoniker(baseURLMoniker, szName, ppmk);
if (SUCCEEDED(hr) && !*ppmk)
hr = E_FAIL;
--- a/embedding/browser/activex/src/plugin/XPConnect.cpp
+++ b/embedding/browser/activex/src/plugin/XPConnect.cpp
@@ -367,17 +367,17 @@ nsScriptablePeer::ConvertVariants(VARIAN
// NOTE: THIS IS AN UGLY BACKWARDS COMPATIBILITY HACK TO WORKAROUND
// XPCOM GLUE'S INABILITY TO FIND A CERTAIN ENTRY POINT IN MOZ1.0.x/NS7.0!
// DO NOT TAUNT THE HACK
if (NS_FAILED(rv))
{
// do_CreateInstance macro is broken so load the component manager by
// hand and get it to create the component.
- HMODULE hlib = ::LoadLibrary("xpcom.dll");
+ HMODULE hlib = ::LoadLibraryW(L"xpcom.dll");
if (hlib)
{
nsIComponentManager *pManager = nsnull; // A frozen interface, even in 1.0.x
typedef nsresult (PR_CALLBACK *Moz1XGetComponentManagerFunc)(nsIComponentManager* *result);
Moz1XGetComponentManagerFunc compMgr = (Moz1XGetComponentManagerFunc)
::GetProcAddress(hlib, "NS_GetComponentManager");
if (compMgr)
{
--- a/extensions/auth/nsAuthSSPI.cpp
+++ b/extensions/auth/nsAuthSSPI.cpp
@@ -47,16 +47,18 @@
#include "nsAuthSSPI.h"
#include "nsIServiceManager.h"
#include "nsIDNSService.h"
#include "nsIDNSRecord.h"
#include "nsNetCID.h"
#include "nsCOMPtr.h"
+#include <windows.h>
+
#define SEC_SUCCESS(Status) ((Status) >= 0)
#ifndef KERB_WRAP_NO_ENCRYPT
#define KERB_WRAP_NO_ENCRYPT 0x80000001
#endif
#ifndef SECBUFFER_PADDING
#define SECBUFFER_PADDING 9
@@ -98,35 +100,35 @@ static const char *MapErrorCode(int rc)
}
#else
#define MapErrorCode(_rc) ""
#endif
//-----------------------------------------------------------------------------
static HINSTANCE sspi_lib;
-static PSecurityFunctionTable sspi;
+static PSecurityFunctionTableW sspi;
static nsresult
InitSSPI()
{
- PSecurityFunctionTable (*initFun)(void);
+ PSecurityFunctionTableW (*initFun)(void);
LOG((" InitSSPI\n"));
- sspi_lib = LoadLibrary("secur32.dll");
+ sspi_lib = LoadLibraryW(L"secur32.dll");
if (!sspi_lib) {
- sspi_lib = LoadLibrary("security.dll");
+ sspi_lib = LoadLibraryW(L"security.dll");
if (!sspi_lib) {
LOG(("SSPI library not found"));
return NS_ERROR_UNEXPECTED;
}
}
- initFun = (PSecurityFunctionTable (*)(void))
+ initFun = (PSecurityFunctionTableW (*)(void))
GetProcAddress(sspi_lib, "InitSecurityInterfaceA");
if (!initFun) {
LOG(("InitSecurityInterfaceA not found"));
return NS_ERROR_UNEXPECTED;
}
sspi = initFun();
if (!sspi) {
@@ -237,43 +239,41 @@ nsAuthSSPI::Init(const char *serviceName
nsresult rv;
// XXX lazy initialization like this assumes that we are single threaded
if (!sspi) {
rv = InitSSPI();
if (NS_FAILED(rv))
return rv;
}
-
- SEC_CHAR *package;
+ SEC_WCHAR *package;
- package = (SEC_CHAR *) pTypeName[(int)mPackage];
-
+ package = (SEC_WCHAR *) pTypeName[(int)mPackage];
if (mPackage != PACKAGE_TYPE_NTLM)
{
rv = MakeSN(serviceName, mServiceName);
if (NS_FAILED(rv))
return rv;
mServiceFlags = serviceFlags;
}
SECURITY_STATUS rc;
- PSecPkgInfo pinfo;
- rc = (sspi->QuerySecurityPackageInfo)(package, &pinfo);
+ PSecPkgInfoW pinfo;
+ rc = (sspi->QuerySecurityPackageInfoW)(package, &pinfo);
if (rc != SEC_E_OK) {
LOG(("%s package not found\n", package));
return NS_ERROR_UNEXPECTED;
}
mMaxTokenLen = pinfo->cbMaxToken;
(sspi->FreeContextBuffer)(pinfo);
TimeStamp useBefore;
- rc = (sspi->AcquireCredentialsHandle)(NULL,
+ rc = (sspi->AcquireCredentialsHandleW)(NULL,
package,
SECPKG_CRED_OUTBOUND,
NULL,
NULL,
NULL,
NULL,
&mCred,
&useBefore);
@@ -331,25 +331,23 @@ nsAuthSSPI::GetNextToken(const void *inT
obd.cBuffers = 1;
obd.pBuffers = &ob;
ob.BufferType = SECBUFFER_TOKEN;
ob.cbBuffer = mMaxTokenLen;
ob.pvBuffer = nsMemory::Alloc(ob.cbBuffer);
if (!ob.pvBuffer)
return NS_ERROR_OUT_OF_MEMORY;
memset(ob.pvBuffer, 0, ob.cbBuffer);
-
- SEC_CHAR *sn;
-
+ SEC_WCHAR *sn;
if (mPackage == PACKAGE_TYPE_NTLM)
sn = NULL;
else
- sn = (SEC_CHAR *) mServiceName.get();
+ sn = (SEC_WCHAR *) mServiceName.get();
- rc = (sspi->InitializeSecurityContext)(&mCred,
+ rc = (sspi->InitializeSecurityContextW)(&mCred,
ctxIn,
sn,
ctxReq,
0,
SECURITY_NATIVE_DREP,
inToken ? &ibd : NULL,
0,
&mCtxt,
@@ -456,17 +454,17 @@ nsAuthSSPI::Wrap(const void *inToken,
PRUint32 *outTokenLen)
{
SECURITY_STATUS rc;
SecBufferDesc ibd;
secBuffers bufs;
SecPkgContext_Sizes sizes;
- rc = (sspi->QueryContextAttributes)(
+ rc = (sspi->QueryContextAttributesW)(
&mCtxt,
SECPKG_ATTR_SIZES,
&sizes);
if (!SEC_SUCCESS(rc))
return NS_ERROR_FAILURE;
ibd.cBuffers = 3;
--- a/gfx/src/thebes/nsSystemFontsWin.cpp
+++ b/gfx/src/thebes/nsSystemFontsWin.cpp
@@ -39,28 +39,22 @@
#include "nsIRenderingContext.h"
#include "gfxWindowsSurface.h"
#include "nsSystemFontsWin.h"
nsresult nsSystemFontsWin::CopyLogFontToNSFont(HDC* aHDC, const LOGFONT* ptrLogFont,
- nsString *aFontName,
- gfxFontStyle *aFontStyle,
- PRBool aIsWide) const
+ nsString *aFontName,
+ gfxFontStyle *aFontStyle) const
{
PRUnichar name[LF_FACESIZE];
name[0] = 0;
- if (aIsWide)
memcpy(name, ptrLogFont->lfFaceName, LF_FACESIZE*2);
- else {
- MultiByteToWideChar(CP_ACP, 0, ptrLogFont->lfFaceName,
- strlen(ptrLogFont->lfFaceName) + 1, name, sizeof(name)/sizeof(name[0]));
- }
*aFontName = name;
// Do Style
aFontStyle->style = FONT_STYLE_NORMAL;
if (ptrLogFont->lfItalic)
{
aFontStyle->style = FONT_STYLE_ITALIC;
}
--- a/gfx/src/thebes/nsSystemFontsWin.h
+++ b/gfx/src/thebes/nsSystemFontsWin.h
@@ -46,17 +46,16 @@ class nsSystemFontsWin
{
public:
nsSystemFontsWin();
nsresult GetSystemFont(nsSystemFontID anID, nsString *aFontName,
gfxFontStyle *aFontStyle) const;
private:
nsresult CopyLogFontToNSFont(HDC* aHDC, const LOGFONT* ptrLogFont,
- nsString *aFontName, gfxFontStyle *aFontStyle,
- PRBool aIsWide = PR_FALSE) const;
+ nsString *aFontName, gfxFontStyle *aFontStyle) const;
nsresult GetSysFontInfo(HDC aHDC, nsSystemFontID anID,
nsString *aFontName,
gfxFontStyle *aFontStyle) const;
};
#endif /* _NS_SYSTEMFONTSWIN_H_ */
--- a/gfx/src/windows/nsDeviceContextWin.cpp
+++ b/gfx/src/windows/nsDeviceContextWin.cpp
@@ -305,17 +305,17 @@ NS_IMETHODIMP nsDeviceContextWin :: SetC
{
DeviceContextImpl::SetCanonicalPixelScale(aScale);
mPixelScale = aScale;
return NS_OK;
}
nsresult nsDeviceContextWin::CopyLogFontToNSFont(HDC* aHDC, const LOGFONT* ptrLogFont,
- nsFont* aFont, PRBool aIsWide) const
+ nsFont* aFont) const
{
PRUnichar name[LF_FACESIZE];
name[0] = 0;
if (aIsWide)
memcpy(name, ptrLogFont->lfFaceName, LF_FACESIZE*2);
else {
MultiByteToWideChar(CP_ACP, 0, ptrLogFont->lfFaceName,
strlen(ptrLogFont->lfFaceName) + 1, name, sizeof(name)/sizeof(name[0]));
--- a/gfx/src/windows/nsDeviceContextWin.h
+++ b/gfx/src/windows/nsDeviceContextWin.h
@@ -96,18 +96,17 @@ protected:
virtual ~nsDeviceContextWin();
void CommonInit(HDC aDC);
nsresult Init(nsNativeDeviceContext aContext, nsIDeviceContext *aOrigContext);
void FindScreen ( nsIScreen** outScreen ) ;
void ComputeClientRectUsingScreen ( nsRect* outRect ) ;
void ComputeFullAreaUsingScreen ( nsRect* outRect ) ;
nsresult GetSysFontInfo(HDC aHDC, nsSystemFontID anID, nsFont* aFont) const;
- nsresult CopyLogFontToNSFont(HDC* aHDC, const LOGFONT* ptrLogFont, nsFont* aFont,
- PRBool aIsWide = PR_FALSE) const;
+ nsresult CopyLogFontToNSFont(HDC* aHDC, const LOGFONT* ptrLogFont, nsFont* aFont) const;
PRBool mCachedClientRect;
PRBool mCachedFullRect;
nsIDrawingSurface* mSurface;
PRUint32 mDepth; // bit depth of device
nsPaletteInfo mPaletteInfo;
float mPixelScale;
--- a/gfx/src/windows/nsFontMetricsWin.cpp
+++ b/gfx/src/windows/nsFontMetricsWin.cpp
@@ -2116,50 +2116,19 @@ nsGlyphAgent::GetGlyphMetrics(HDC
// aGlyphIndex should be 0 if the caller doesn't know the glyph index of the char.
DWORD
nsGlyphAgent::GetGlyphMetrics(HDC aDC,
PRUnichar aChar,
PRUint16 aGlyphIndex,
GLYPHMETRICS* aGlyphMetrics)
{
memset(aGlyphMetrics, 0, sizeof(GLYPHMETRICS)); // UMR: bug 46438
- if (eGlyphAgent_UNKNOWN == mState) { // first time we have been in this function
- // see if this platform implements GetGlyphOutlineW()
- DWORD len = GetGlyphOutlineW(aDC, aChar, GGO_METRICS, aGlyphMetrics, 0, nsnull, &mMat);
- if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) {
- // next time, we won't bother trying GetGlyphOutlineW()
- mState = eGlyphAgent_ANSI;
- }
- else {
- // all is well with GetGlyphOutlineW(), we will be using it from now on
mState = eGlyphAgent_UNICODE;
- return len;
- }
- }
-
- if (eGlyphAgent_UNICODE == mState) {
return GetGlyphOutlineW(aDC, aChar, GGO_METRICS, aGlyphMetrics, 0, nsnull, &mMat);
- }
-
- // Otherwise, we are on a platform that doesn't implement GetGlyphOutlineW()
- // (see Q241358: The GetGlyphOutlineW Function Fails on Windows 95 & 98
- // http://support.microsoft.com/support/kb/articles/Q241/3/58.ASP)
- // we will use glyph indices as a work around.
- if (0 == aGlyphIndex) { // caller doesn't know the glyph index, so find it
- nsAutoChar16Buffer buf;
- if (NS_SUCCEEDED(GetGlyphIndices(aDC, nsnull, &aChar, 1, buf)))
- aGlyphIndex = *(buf.Elements());
- }
- if (0 < aGlyphIndex) {
- return GetGlyphOutlineA(aDC, aGlyphIndex, GGO_METRICS | GGO_GLYPH_INDEX, aGlyphMetrics, 0, nsnull, &mMat);
- }
-
- // if we ever reach here, something went wrong in GetGlyphIndices() above
- // because the current font in aDC wasn't a Unicode font
- return GDI_ERROR;
+
}
// the global glyph agent that we will be using
nsGlyphAgent gGlyphAgent;
#ifdef MOZ_MATHML
// the common part of GetBoundingMetrics used by nsFontWinUnicode
--- a/gfx/thebes/src/gfxWindowsFonts.cpp
+++ b/gfx/thebes/src/gfxWindowsFonts.cpp
@@ -335,23 +335,23 @@ gfxWindowsFont::ComputeMetrics()
mMetrics->maxHeight = metrics.tmHeight;
mMetrics->maxAscent = metrics.tmAscent;
mMetrics->maxDescent = metrics.tmDescent;
mMetrics->maxAdvance = metrics.tmMaxCharWidth;
mMetrics->aveCharWidth = PR_MAX(1, metrics.tmAveCharWidth);
// Cache the width of a single space.
SIZE size;
- GetTextExtentPoint32(dc, " ", 1, &size);
+ GetTextExtentPoint32W(dc, L" ", 1, &size);
mMetrics->spaceWidth = ROUND(size.cx);
mSpaceGlyph = 0;
if (metrics.tmPitchAndFamily & TMPF_TRUETYPE) {
WORD glyph;
- DWORD ret = GetGlyphIndicesA(dc, " ", 1, &glyph,
+ DWORD ret = GetGlyphIndicesW(dc, L" ", 1, &glyph,
GGI_MARK_NONEXISTING_GLYPHS);
if (ret != GDI_ERROR && glyph != 0xFFFF) {
mSpaceGlyph = glyph;
}
}
SelectObject(dc, oldFont);
--- a/gfx/thebes/src/gfxWindowsSurface.cpp
+++ b/gfx/thebes/src/gfxWindowsSurface.cpp
@@ -163,61 +163,43 @@ gfxWindowsSurface::OptimizeToDDB(HDC dc,
tmpCtx.SetSource(this);
tmpCtx.Paint();
gfxWindowsSurface *raw = (gfxWindowsSurface*) (wsurf.get());
NS_ADDREF(raw);
return raw;
}
-static char*
-GetACPString(const nsAString& aStr)
-{
- int acplen = aStr.Length() * 2 + 1;
- char * acp = new char[acplen];
- if(acp) {
- int outlen = ::WideCharToMultiByte(CP_ACP, 0,
- PromiseFlatString(aStr).get(),
- aStr.Length(),
- acp, acplen, NULL, NULL);
- if (outlen > 0)
- acp[outlen] = '\0'; // null terminate
- }
- return acp;
-}
-
nsresult gfxWindowsSurface::BeginPrinting(const nsAString& aTitle,
const nsAString& aPrintToFileName)
{
#define DOC_TITLE_LENGTH 30
- DOCINFO docinfo;
+ DOCINFOW docinfo;
nsString titleStr;
titleStr = aTitle;
if (titleStr.Length() > DOC_TITLE_LENGTH) {
titleStr.SetLength(DOC_TITLE_LENGTH-3);
titleStr.AppendLiteral("...");
}
- char *title = GetACPString(titleStr);
-
- char *docName = nsnull;
+ nsPromiseFlatString flatTitleStr(titleStr);
+ const PRUnichar *title = (const PRUnichar*)(flatTitleStr.get());
+ const PRUnichar *docName = nsnull;
+ nsPromiseFlatString printToFileNameStr(aPrintToFileName);
if (!aPrintToFileName.IsEmpty()) {
- docName = ToNewCString(aPrintToFileName);
+ docName = (const PRUnichar*)(printToFileNameStr.get());
}
-
docinfo.cbSize = sizeof(docinfo);
- docinfo.lpszDocName = title ? title : "Mozilla Document";
+ docinfo.lpszDocName = title ? title : L"Mozilla Document";
docinfo.lpszOutput = docName;
docinfo.lpszDatatype = NULL;
docinfo.fwType = 0;
- ::StartDoc(mDC, &docinfo);
+ ::StartDocW(mDC, &docinfo);
- delete [] title;
- if (docName != nsnull) nsMemory::Free(docName);
return NS_OK;
}
nsresult gfxWindowsSurface::EndPrinting()
{
::EndDoc(mDC);
return NS_OK;
--- a/intl/uconv/src/nsWinCharset.cpp
+++ b/intl/uconv/src/nsWinCharset.cpp
@@ -128,35 +128,35 @@ nsPlatformCharset::GetCharset(nsPlatform
return NS_OK;
}
NS_IMETHODIMP
nsPlatformCharset::GetDefaultCharsetForLocale(const nsAString& localeName, nsACString& oResult)
{
nsCOMPtr<nsIWin32Locale> winLocale;
LCID localeAsLCID;
- char acp_name[6];
+ PRUnichar acp_name[6];
//
// convert locale name to a code page (through the LCID)
//
nsresult rv;
oResult.Truncate();
winLocale = do_GetService(NS_WIN32LOCALE_CONTRACTID, &rv);
if (NS_FAILED(rv)) { return rv; }
rv = winLocale->GetPlatformLocale(localeName, &localeAsLCID);
if (NS_FAILED(rv)) { return rv; }
- if (GetLocaleInfo(localeAsLCID, LOCALE_IDEFAULTANSICODEPAGE, acp_name, sizeof(acp_name))==0) {
+ if (GetLocaleInfoW(localeAsLCID, LOCALE_IDEFAULTANSICODEPAGE, acp_name, sizeof(acp_name))==0) {
return NS_ERROR_FAILURE;
}
nsAutoString acp_key(NS_LITERAL_STRING("acp."));
- acp_key.AppendWithConversion(acp_name);
+ acp_key.Append(acp_name);
return MapToCharset(acp_key, oResult);
}
NS_IMETHODIMP
nsPlatformCharset::Init()
{
return NS_OK;
--- a/ipc/ipcd/client/src/ipcConnectionWin.cpp
+++ b/ipc/ipcd/client/src/ipcConnectionWin.cpp
@@ -107,17 +107,17 @@ ipcThreadWindowProc(HWND hWnd, UINT uMsg
if (uMsg == IPC_WM_SENDMSG) {
ipcMessage *msg = (ipcMessage *) lParam;
if (msg) {
LOG((" sending message...\n"));
COPYDATASTRUCT cd;
cd.dwData = GetCurrentProcessId();
cd.cbData = (DWORD) msg->MsgLen();
cd.lpData = (PVOID) msg->MsgBuf();
- SendMessageA(ipcDaemonHwnd, WM_COPYDATA, (WPARAM) hWnd, (LPARAM) &cd);
+ SendMessage(ipcDaemonHwnd, WM_COPYDATA, (WPARAM) hWnd, (LPARAM) &cd);
LOG((" done.\n"));
delete msg;
}
return 0;
}
if (uMsg == IPC_WM_CALLBACK) {
ipcCallbackFunc func = (ipcCallbackFunc) wParam;
--- a/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp
+++ b/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp
@@ -58,16 +58,17 @@
#include "nsIMIMEService.h"
#include "nsCExternalHandlerService.h"
#include "nsDirectoryServiceDefs.h"
// we need windows.h to read out registry information...
#include <windows.h>
#include <shellapi.h>
#include <shlobj.h>
+#include <wchar.h>
struct ICONFILEHEADER {
PRUint16 ifhReserved;
PRUint16 ifhType;
PRUint16 ifhCount;
};
struct ICONENTRY {
@@ -184,17 +185,17 @@ NS_IMETHODIMP nsIconChannel::GetURI(nsIU
}
NS_IMETHODIMP
nsIconChannel::Open(nsIInputStream **_retval)
{
return MakeInputStream(_retval, PR_FALSE);
}
-nsresult nsIconChannel::ExtractIconInfoFromUrl(nsIFile ** aLocalFile, PRUint32 * aDesiredImageSize, nsACString &aContentType, nsACString &aFileExtension)
+nsresult nsIconChannel::ExtractIconInfoFromUrl(nsIFile ** aLocalFile, PRUint32 * aDesiredImageSize, nsCString &aContentType, nsCString &aFileExtension)
{
nsresult rv = NS_OK;
nsCOMPtr<nsIMozIconURI> iconURI (do_QueryInterface(mUrl, &rv));
NS_ENSURE_SUCCESS(rv, rv);
iconURI->GetImageSize(aDesiredImageSize);
iconURI->GetContentType(aContentType);
iconURI->GetFileExtension(aFileExtension);
@@ -231,61 +232,60 @@ NS_IMETHODIMP nsIconChannel::AsyncOpen(n
mListener = aListener;
// Add ourself to the load group, if available
if (mLoadGroup)
mLoadGroup->AddRequest(this, nsnull);
}
return rv;
}
-static DWORD GetSpecialFolderIcon(nsIFile* aFile, int aFolder, SHFILEINFO* aSFI, UINT aInfoFlags)
+static DWORD GetSpecialFolderIcon(nsIFile* aFile, int aFolder, SHFILEINFOW* aSFI, UINT aInfoFlags)
{
DWORD shellResult = 0;
if (!aFile)
return shellResult;
- char fileNativePath[MAX_PATH];
- nsCAutoString fileNativePathStr;
- aFile->GetNativePath(fileNativePathStr);
- ::GetShortPathName(fileNativePathStr.get(), fileNativePath, sizeof(fileNativePath));
+ PRUnichar fileNativePath[MAX_PATH];
+ nsAutoString fileNativePathStr;
+ aFile->GetPath(fileNativePathStr);
+ ::GetShortPathNameW(fileNativePathStr.get(), fileNativePath, sizeof(fileNativePath));
LPITEMIDLIST idList;
HRESULT hr = ::SHGetSpecialFolderLocation(NULL, aFolder, &idList);
if (SUCCEEDED(hr)) {
- char specialNativePath[MAX_PATH];
- ::SHGetPathFromIDList(idList, specialNativePath);
- ::GetShortPathName(specialNativePath, specialNativePath, sizeof(specialNativePath));
-
- if (nsDependentCString(fileNativePath).EqualsIgnoreCase(specialNativePath)) {
+ PRUnichar specialNativePath[MAX_PATH];
+ ::SHGetPathFromIDListW(idList, specialNativePath);
+ ::GetShortPathNameW(specialNativePath, specialNativePath, sizeof(specialNativePath));
+ if (!wcsicmp(fileNativePath,specialNativePath)) {
aInfoFlags |= (SHGFI_PIDL | SHGFI_SYSICONINDEX);
- shellResult = ::SHGetFileInfo((LPCTSTR)(LPCITEMIDLIST)idList, 0, aSFI,
- sizeof(SHFILEINFO), aInfoFlags);
+ shellResult = ::SHGetFileInfoW((LPCWSTR)(LPCITEMIDLIST)idList, 0, aSFI,
+ sizeof(SHFILEINFOW), aInfoFlags);
IMalloc* pMalloc;
hr = ::SHGetMalloc(&pMalloc);
if (SUCCEEDED(hr)) {
pMalloc->Free(idList);
pMalloc->Release();
}
}
}
return shellResult;
}
nsresult nsIconChannel::MakeInputStream(nsIInputStream** _retval, PRBool nonBlocking)
{
nsXPIDLCString contentType;
- nsCAutoString filePath;
+ nsCString filePath;
nsCOMPtr<nsIFile> localFile; // file we want an icon for
PRUint32 desiredImageSize;
nsresult rv = ExtractIconInfoFromUrl(getter_AddRefs(localFile), &desiredImageSize, contentType, filePath);
NS_ENSURE_SUCCESS(rv, rv);
// if the file exists, we are going to use it's real attributes...otherwise we only want to use it for it's extension...
- SHFILEINFO sfi;
+ SHFILEINFOW sfi;
UINT infoFlags = SHGFI_ICON;
PRBool fileExists = PR_FALSE;
if (localFile)
{
rv = localFile->Normalize();
NS_ENSURE_SUCCESS(rv, rv);
@@ -337,17 +337,19 @@ nsresult nsIconChannel::MakeInputStream(
// There are other "Special Folders" and Namespace entities that we are not
// fetching icons for, see:
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/enums/csidl.asp
// If we ever need to get them, code to do so would be inserted here.
// Not a special folder, or something else failed above.
if (!shellResult)
- shellResult = ::SHGetFileInfo(filePath.get(), FILE_ATTRIBUTE_ARCHIVE, &sfi, sizeof(sfi), infoFlags);
+ shellResult = ::SHGetFileInfoW(
+ NS_ConvertUTF8toUTF16(filePath).get(),
+ FILE_ATTRIBUTE_ARCHIVE, &sfi, sizeof(sfi), infoFlags);
if (shellResult && sfi.hIcon)
{
// we got a handle to an icon. Now we want to get a bitmap for the icon using GetIconInfo....
ICONINFO iconInfo;
if (GetIconInfo(sfi.hIcon, &iconInfo))
{
// we got the bitmaps, first find out their size
--- a/modules/libpr0n/decoders/icon/win/nsIconChannel.h
+++ b/modules/libpr0n/decoders/icon/win/nsIconChannel.h
@@ -72,13 +72,13 @@ protected:
PRInt32 mContentLength;
nsCOMPtr<nsILoadGroup> mLoadGroup;
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
nsCOMPtr<nsISupports> mOwner;
nsCOMPtr<nsIInputStreamPump> mPump;
nsCOMPtr<nsIStreamListener> mListener;
- nsresult ExtractIconInfoFromUrl(nsIFile ** aLocalFile, PRUint32 * aDesiredImageSize, nsACString &aContentType, nsACString &aFileExtension);
+ nsresult ExtractIconInfoFromUrl(nsIFile ** aLocalFile, PRUint32 * aDesiredImageSize, nsCString &aContentType, nsCString &aFileExtension);
nsresult MakeInputStream(nsIInputStream** _retval, PRBool nonBlocking);
};
#endif /* nsIconChannel_h___ */
--- a/modules/oji/src/scd.cpp
+++ b/modules/oji/src/scd.cpp
@@ -95,17 +95,17 @@ nsSymantecDebugManager::SetDebugAgentPas
/* set up by aHiddenFrameClass in CNetscapeApp::InitInstance */
err = SetWindowLong(win, 0, pwd);
if (err == 0) {
// PR_LOG(NSJAVA, PR_LOG_ALWAYS,
// ("SetWindowLong returned %ld (err=%d)\n", err, GetLastError()));
/* continue so that we try to wake up the DebugManager */
}
- sem = OpenSemaphore(SEMAPHORE_MODIFY_STATE, FALSE, "Netscape-Symantec Debugger");
+ sem = OpenSemaphoreW(SEMAPHORE_MODIFY_STATE, FALSE, L"Netscape-Symantec Debugger");
if (sem) {
ReleaseSemaphore(sem, 1, NULL);
CloseHandle(sem);
}
return NS_OK;
#else
return NS_ERROR_FAILURE;
#endif
--- a/modules/plugin/base/src/nsPluginDirServiceProvider.cpp
+++ b/modules/plugin/base/src/nsPluginDirServiceProvider.cpp
@@ -61,42 +61,42 @@ ClearVersion(verBlock *ver)
{
ver->wMajor = 0;
ver->wMinor = 0;
ver->wRelease = 0;
ver->wBuild = 0;
}
static BOOL
-FileExists(LPCSTR szFile)
+FileExists(wchar_t* szFile)
{
- return GetFileAttributes(szFile) != 0xFFFFFFFF;
+ return GetFileAttributesW(szFile) != 0xFFFFFFFF;
}
// Get file version information from a file
static BOOL
-GetFileVersion(LPSTR szFile, verBlock *vbVersion)
+GetFileVersion(wchar_t* szFile, verBlock *vbVersion)
{
UINT uLen;
UINT dwLen;
BOOL bRv;
DWORD dwHandle;
LPVOID lpData;
LPVOID lpBuffer;
VS_FIXEDFILEINFO *lpBuffer2;
ClearVersion(vbVersion);
if (FileExists(szFile)) {
bRv = TRUE;
- dwLen = GetFileVersionInfoSize(szFile, &dwHandle);
+ dwLen = GetFileVersionInfoSizeW(szFile, &dwHandle);
lpData = (LPVOID)malloc(dwLen);
uLen = 0;
- if (lpData && GetFileVersionInfo(szFile, dwHandle, dwLen, lpData) != 0) {
- if (VerQueryValue(lpData, "\\", &lpBuffer, &uLen) != 0) {
+ if (lpData && GetFileVersionInfoW(szFile, dwHandle, dwLen, lpData) != 0) {
+ if (VerQueryValueW(lpData, L"\\", &lpBuffer, &uLen) != 0) {
lpBuffer2 = (VS_FIXEDFILEINFO *)lpBuffer;
vbVersion->wMajor = HIWORD(lpBuffer2->dwFileVersionMS);
vbVersion->wMinor = LOWORD(lpBuffer2->dwFileVersionMS);
vbVersion->wRelease = HIWORD(lpBuffer2->dwFileVersionLS);
vbVersion->wBuild = LOWORD(lpBuffer2->dwFileVersionLS);
}
}
@@ -119,25 +119,25 @@ CopyVersion(verBlock *ver1, verBlock *ve
ver1->wRelease = ver2->wRelease;
ver1->wBuild = ver2->wBuild;
}
// Convert a string version to a version struct
static void
TranslateVersionStr(const char* szVersion, verBlock *vbVersion)
{
- LPSTR szNum1 = NULL;
- LPSTR szNum2 = NULL;
- LPSTR szNum3 = NULL;
- LPSTR szNum4 = NULL;
- LPSTR szJavaBuild = NULL;
+ char* szNum1 = NULL;
+ char* szNum2 = NULL;
+ char* szNum3 = NULL;
+ char* szNum4 = NULL;
+ char* szJavaBuild = NULL;
- char *strVer = nsnull;
+ char* strVer = nsnull;
if (szVersion) {
- strVer = PL_strdup(szVersion);
+ strVer = strdup(szVersion);
}
if (!strVer) {
// Out of memory
ClearVersion(vbVersion);
return;
}
@@ -152,17 +152,17 @@ TranslateVersionStr(const char* szVersio
szNum3 = strtok(NULL, ".");
szNum4 = strtok(NULL, ".");
vbVersion->wMajor = szNum1 ? atoi(szNum1) : 0;
vbVersion->wMinor = szNum2 ? atoi(szNum2) : 0;
vbVersion->wRelease = szNum3 ? atoi(szNum3) : 0;
vbVersion->wBuild = szNum4 ? atoi(szNum4) : 0;
- PL_strfree(strVer);
+ free(strVer);
}
// Compare two version struct, return zero if the same
static int
CompareVersion(verBlock vbVersionOld, verBlock vbVersionNew)
{
if (vbVersionOld.wMajor > vbVersionNew.wMajor) {
return 4;
@@ -190,36 +190,38 @@ CompareVersion(verBlock vbVersionOld, ve
/* the versions are all the same */
return 0;
}
// Indicate whether we should try to use the new NPRuntime-based Java
// Plug-In if it's available
static PRBool
-TryToUseNPRuntimeJavaPlugIn(const char* javaVersion)
+TryToUseNPRuntimeJavaPlugIn(const wchar_t* javaVersion)
{
HKEY javaKey = NULL;
- char keyName[_MAX_PATH];
- keyName[0] = 0;
- PL_strcat(keyName, "Software\\JavaSoft\\Java Plug-in\\");
- PL_strcat(keyName, javaVersion);
+ wchar_t keyName[_MAX_PATH];
+
+ wcsncpy(keyName, L"Software\\JavaSoft\\Java Plug-in\\", wcslen(L"Software\\JavaSoft\\Java Plug-in\\"));
+ wcscpy(keyName, javaVersion);
+
DWORD val;
DWORD valSize = sizeof(DWORD);
- if (ERROR_SUCCESS != ::RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+ if (ERROR_SUCCESS != ::RegOpenKeyExW(HKEY_LOCAL_MACHINE,
keyName, 0, KEY_READ, &javaKey)) {
return FALSE;
}
// Look for "UseNewJavaPlugin"
- if (ERROR_SUCCESS != ::RegQueryValueEx(javaKey, "UseNewJavaPlugin",
- NULL, NULL,
- (LPBYTE) &val,
- &valSize)) {
+ if (ERROR_SUCCESS != ::RegQueryValueExW(javaKey,
+ L"UseNewJavaPlugin",
+ NULL, NULL,
+ (LPBYTE) &val,
+ &valSize)) {
val = 0;
}
::RegCloseKey(javaKey);
return (val == 0) ? PR_FALSE : PR_TRUE;
}
@@ -257,63 +259,63 @@ nsPluginDirServiceProvider::GetFile(cons
*_retval = nsnull;
*persistant = PR_FALSE;
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (!prefs) {
return rv;
}
- if (nsCRT::strcmp(prop, NS_WIN_4DOTX_SCAN_KEY) == 0) {
+ if (strcmp(prop, NS_WIN_4DOTX_SCAN_KEY) == 0) {
// Check our prefs to see if scanning the 4.x folder has been
// explictly overriden failure to get the pref is okay, we'll do
// what we've been doing -- a filtered scan
PRBool bScan4x;
if (NS_SUCCEEDED(prefs->GetBoolPref(NS_WIN_4DOTX_SCAN_KEY, &bScan4x)) &&
!bScan4x) {
return rv;
}
// Look for the plugin folder that the user has in their
// Communicator 4x install
HKEY keyloc;
long result;
DWORD type;
- char szKey[_MAX_PATH] = "Software\\Netscape\\Netscape Navigator";
- char path[_MAX_PATH];
+ wchar_t szKey[_MAX_PATH] = L"Software\\Netscape\\Netscape Navigator";
+ wchar_t path[_MAX_PATH];
- result = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, KEY_READ, &keyloc);
+ result = ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, szKey, 0, KEY_READ, &keyloc);
if (result == ERROR_SUCCESS) {
- char current_version[80];
+ wchar_t current_version[80];
DWORD length = sizeof(current_version);
- result = ::RegQueryValueEx(keyloc, "CurrentVersion", NULL, &type,
+ result = ::RegQueryValueExW(keyloc, L"CurrentVersion", NULL, &type,
(LPBYTE)¤t_version, &length);
::RegCloseKey(keyloc);
- PL_strcat(szKey, "\\");
- PL_strcat(szKey, current_version);
- PL_strcat(szKey, "\\Main");
- result = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, KEY_READ, &keyloc);
+ wcscat(szKey, L"\\");
+ wcscat(szKey, current_version);
+ wcscat(szKey, L"\\Main");
+ result = ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, szKey, 0, KEY_READ, &keyloc);
if (result == ERROR_SUCCESS) {
DWORD pathlen = sizeof(path);
- result = ::RegQueryValueEx(keyloc, "Plugins Directory", NULL, &type,
+ result = ::RegQueryValueExW(keyloc, L"Plugins Directory", NULL, &type,
(LPBYTE)&path, &pathlen);
if (result == ERROR_SUCCESS) {
- rv = NS_NewNativeLocalFile(nsDependentCString(path), PR_TRUE,
- getter_AddRefs(localFile));
+ rv = NS_NewLocalFile(nsDependentString(path), PR_TRUE,
+ getter_AddRefs(localFile));
}
::RegCloseKey(keyloc);
}
}
- } else if (nsCRT::strcmp(prop, NS_WIN_JRE_SCAN_KEY) == 0) {
+ } else if (strcmp(prop, NS_WIN_JRE_SCAN_KEY) == 0) {
nsXPIDLCString strVer;
#ifdef OJI
if (NS_FAILED(prefs->GetCharPref(prop, getter_Copies(strVer))))
#endif /* OJI */
return NS_ERROR_FAILURE;
verBlock minVer;
TranslateVersionStr(strVer.get(), &minVer);
@@ -323,216 +325,217 @@ nsPluginDirServiceProvider::GetFile(cons
HKEY entryloc;
FILETIME modTime;
DWORD type;
DWORD index = 0;
DWORD numChars = _MAX_PATH;
DWORD pathlen;
verBlock maxVer;
ClearVersion(&maxVer);
- char curKey[_MAX_PATH] = "Software\\JavaSoft\\Java Runtime Environment";
- char path[_MAX_PATH];
+ wchar_t curKey[_MAX_PATH] = L"Software\\JavaSoft\\Java Runtime Environment";
+ wchar_t path[_MAX_PATH];
+
// Add + 15 to prevent buffer overrun when adding \bin (+ optionally
// \new_plugin)
#define JAVA_PATH_SIZE _MAX_PATH + 15
- char newestPath[JAVA_PATH_SIZE];
- const char mozPath[_MAX_PATH] = "Software\\mozilla.org\\Mozilla";
- char browserJavaVersion[_MAX_PATH];
+ wchar_t newestPath[JAVA_PATH_SIZE];
+ const wchar_t mozPath[_MAX_PATH] = L"Software\\mozilla.org\\Mozilla";
+ wchar_t browserJavaVersion[_MAX_PATH];
PRBool tryNPRuntimeJavaPlugIn = PR_FALSE;
newestPath[0] = 0;
- LONG result = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, curKey, 0, KEY_READ,
+ LONG result = ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, curKey, 0, KEY_READ,
&baseloc);
if (ERROR_SUCCESS != result)
return NS_ERROR_FAILURE;
// Look for "BrowserJavaVersion"
- if (ERROR_SUCCESS != ::RegQueryValueEx(baseloc, "BrowserJavaVersion", NULL,
+ if (ERROR_SUCCESS != ::RegQueryValueExW(baseloc, L"BrowserJavaVersion", NULL,
NULL, (LPBYTE)&browserJavaVersion,
&numChars))
browserJavaVersion[0] = 0;
// We must enumerate through the keys because what if there is
// more than one version?
do {
path[0] = 0;
numChars = _MAX_PATH;
pathlen = sizeof(path);
- result = ::RegEnumKeyEx(baseloc, index, curKey, &numChars, NULL, NULL,
+ result = ::RegEnumKeyExW(baseloc, index, curKey, &numChars, NULL, NULL,
NULL, &modTime);
index++;
// Skip major.minor as it always points to latest in its family
numChars = 0;
- for (char *p = curKey; *p; p++) {
+ for (wchar_t *p = curKey; *p; p++) { // can I do this with wchar_t xxx?
if (*p == '.') {
numChars++;
}
}
if (numChars < 2)
continue;
if (ERROR_SUCCESS == result) {
- if (ERROR_SUCCESS == ::RegOpenKeyEx(baseloc, curKey, 0,
+ if (ERROR_SUCCESS == ::RegOpenKeyExW(baseloc, curKey, 0,
KEY_QUERY_VALUE, &keyloc)) {
// We have a sub key
- if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, "JavaHome", NULL,
+ if (ERROR_SUCCESS == ::RegQueryValueExW(keyloc, L"JavaHome", NULL,
&type, (LPBYTE)&path,
&pathlen)) {
verBlock curVer;
- TranslateVersionStr(curKey, &curVer);
+ TranslateVersionStr(NS_ConvertUTF16toUTF8(curKey).get(), &curVer);
if (CompareVersion(curVer, minVer) >= 0) {
- if (!strncmp(browserJavaVersion, curKey, _MAX_PATH)) {
- PL_strcpy(newestPath, path);
+ if (!wcsncmp(browserJavaVersion, curKey, _MAX_PATH)) {
+ wcscpy(newestPath, path);
tryNPRuntimeJavaPlugIn = TryToUseNPRuntimeJavaPlugIn(curKey);
::RegCloseKey(keyloc);
break;
}
if (CompareVersion(curVer, maxVer) >= 0) {
- PL_strcpy(newestPath, path);
+ wcscpy(newestPath, path);
CopyVersion(&maxVer, &curVer);
tryNPRuntimeJavaPlugIn = TryToUseNPRuntimeJavaPlugIn(curKey);
}
}
}
::RegCloseKey(keyloc);
}
}
} while (ERROR_SUCCESS == result);
::RegCloseKey(baseloc);
// If nothing is found, then don't add \bin dir and don't set
// CurrentVersion for Mozilla
if (newestPath[0] != 0) {
- if (ERROR_SUCCESS == ::RegCreateKeyEx(HKEY_LOCAL_MACHINE, mozPath, 0,
+ if (ERROR_SUCCESS == ::RegCreateKeyExW(HKEY_LOCAL_MACHINE, mozPath, 0,
NULL, REG_OPTION_NON_VOLATILE,
KEY_SET_VALUE|KEY_QUERY_VALUE,
NULL, &entryloc, NULL)) {
- if (ERROR_SUCCESS != ::RegQueryValueEx(entryloc, "CurrentVersion", 0,
+ if (ERROR_SUCCESS != ::RegQueryValueExW(entryloc, L"CurrentVersion", 0,
NULL, NULL, NULL)) {
- ::RegSetValueEx(entryloc, "CurrentVersion", 0, REG_SZ,
+ ::RegSetValueExW(entryloc, L"CurrentVersion", 0, REG_SZ,
(const BYTE*)MOZILLA_VERSION,
sizeof(MOZILLA_VERSION));
}
::RegCloseKey(entryloc);
}
- PL_strcat(newestPath,"\\bin");
+ wcscat(newestPath,L"\\bin");
// See whether we should use the new NPRuntime-based Java Plug-In:
// - If tryNPRuntimeJavaPlugIn is true, and
// - If the appropriate subdirectory actually exists
// Note that this is a temporary code path until the old
// OJI-based Java Plug-In isn't being shipped alongside the new
// one any more.
if (tryNPRuntimeJavaPlugIn) {
// See whether the "new_plugin" directory exists
- char tmpPath[JAVA_PATH_SIZE];
- PL_strcpy(tmpPath, newestPath);
- PL_strcat(tmpPath, "\\new_plugin");
+ wchar_t tmpPath[JAVA_PATH_SIZE];
+ wcscpy(tmpPath, newestPath);
+ wcscat(tmpPath, L"\\new_plugin");
nsCOMPtr<nsILocalFile> tmpFile;
- if (NS_SUCCEEDED(NS_NewNativeLocalFile(nsDependentCString(tmpPath),
- PR_TRUE,
- getter_AddRefs(tmpFile))) &&
+ if (NS_SUCCEEDED(NS_NewLocalFile(nsDependentString(tmpPath),
+ PR_TRUE,
+ getter_AddRefs(tmpFile))) &&
tmpFile) {
PRBool exists = PR_FALSE;
PRBool isDir = PR_FALSE;
if (NS_SUCCEEDED(tmpFile->Exists(&exists)) && exists &&
NS_SUCCEEDED(tmpFile->IsDirectory(&isDir)) && isDir) {
// Assume we're supposed to use this as the search
// directory for the Java Plug-In instead of the normal
// one
- PL_strcpy(newestPath, tmpPath);
+ wcscpy(newestPath, tmpPath);
}
}
}
- rv = NS_NewNativeLocalFile(nsDependentCString(newestPath), PR_TRUE,
- getter_AddRefs(localFile));
+ rv = NS_NewLocalFile(nsDependentString(newestPath), PR_TRUE,
+ getter_AddRefs(localFile));
}
- } else if (nsCRT::strcmp(prop, NS_WIN_QUICKTIME_SCAN_KEY) == 0) {
+ } else if (strcmp(prop, NS_WIN_QUICKTIME_SCAN_KEY) == 0) {
nsXPIDLCString strVer;
if (NS_FAILED(prefs->GetCharPref(prop, getter_Copies(strVer))))
return NS_ERROR_FAILURE;
verBlock minVer;
TranslateVersionStr(strVer.get(), &minVer);
// Look for the Quicktime system installation plugins directory
HKEY keyloc;
long result;
DWORD type;
verBlock qtVer;
ClearVersion(&qtVer);
- char path[_MAX_PATH];
+ wchar_t path[_MAX_PATH];
DWORD pathlen = sizeof(path);
// First we need to check the version of Quicktime via checking
// the EXE's version table
- if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, "software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\QuickTimePlayer.exe", 0, KEY_READ, &keyloc)) {
- if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, NULL, NULL, &type,
- (LPBYTE)&path, &pathlen)) {
- GetFileVersion((char*)path, &qtVer);
+ if (ERROR_SUCCESS == ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\QuickTimePlayer.exe", 0, KEY_READ, &keyloc)) {
+ if (ERROR_SUCCESS == ::RegQueryValueExW(keyloc, NULL, NULL, &type,
+ (LPBYTE)&path, &pathlen)) {
+ GetFileVersion(path, &qtVer);
}
::RegCloseKey(keyloc);
}
if (CompareVersion(qtVer, minVer) < 0)
return rv;
- if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, "software\\Apple Computer, Inc.\\QuickTime", 0, KEY_READ, &keyloc)) {
+ if (ERROR_SUCCESS == ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"software\\Apple Computer, Inc.\\QuickTime", 0, KEY_READ, &keyloc)) {
DWORD pathlen = sizeof(path);
- result = ::RegQueryValueEx(keyloc, "InstallDir", NULL, &type,
+ result = ::RegQueryValueExW(keyloc, L"InstallDir", NULL, &type,
(LPBYTE)&path, &pathlen);
- PL_strcat(path, "\\Plugins");
+ wcscat(path, L"\\Plugins");
if (result == ERROR_SUCCESS)
- rv = NS_NewNativeLocalFile(nsDependentCString(path), PR_TRUE,
- getter_AddRefs(localFile));
+ rv = NS_NewLocalFile(nsDependentString(path), PR_TRUE,
+ getter_AddRefs(localFile));
::RegCloseKey(keyloc);
}
- } else if (nsCRT::strcmp(prop, NS_WIN_WMP_SCAN_KEY) == 0) {
+ } else if (strcmp(prop, NS_WIN_WMP_SCAN_KEY) == 0) {
nsXPIDLCString strVer;
if (NS_FAILED(prefs->GetCharPref(prop, getter_Copies(strVer))))
return NS_ERROR_FAILURE;
verBlock minVer;
TranslateVersionStr(strVer.get(), &minVer);
// Look for Windows Media Player system installation plugins directory
HKEY keyloc;
DWORD type;
verBlock wmpVer;
ClearVersion(&wmpVer);
- char path[_MAX_PATH];
+ wchar_t path[_MAX_PATH];
DWORD pathlen = sizeof(path);
// First we need to check the version of WMP
- if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, "software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\wmplayer.exe", 0, KEY_READ, &keyloc)) {
- if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, NULL, NULL, &type,
- (LPBYTE)&path, &pathlen)) {
- GetFileVersion((char*)path, &wmpVer);
+ if (ERROR_SUCCESS == ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\wmplayer.exe", 0, KEY_READ, &keyloc)) {
+ if (ERROR_SUCCESS == ::RegQueryValueExW(keyloc, NULL, NULL, &type,
+ (LPBYTE)&path, &pathlen)) {
+ GetFileVersion(path, &wmpVer);
}
::RegCloseKey(keyloc);
}
if (CompareVersion(wmpVer, minVer) < 0)
return rv;
- if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- "software\\Microsoft\\MediaPlayer", 0,
+ if (ERROR_SUCCESS == ::RegOpenKeyExW(HKEY_LOCAL_MACHINE,
+ L"software\\Microsoft\\MediaPlayer", 0,
KEY_READ, &keyloc)) {
- if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, "Installation Directory",
+ if (ERROR_SUCCESS == ::RegQueryValueExW(keyloc, L"Installation Directory",
NULL, &type, (LPBYTE)&path,
&pathlen)) {
- rv = NS_NewNativeLocalFile(nsDependentCString(path), PR_TRUE,
- getter_AddRefs(localFile));
+ rv = NS_NewLocalFile(nsDependentString(path), PR_TRUE,
+ getter_AddRefs(localFile));
}
::RegCloseKey(keyloc);
}
- } else if (nsCRT::strcmp(prop, NS_WIN_ACROBAT_SCAN_KEY) == 0) {
+ } else if (strcmp(prop, NS_WIN_ACROBAT_SCAN_KEY) == 0) {
nsXPIDLCString strVer;
if (NS_FAILED(prefs->GetCharPref(prop, getter_Copies(strVer)))) {
return NS_ERROR_FAILURE;
}
verBlock minVer;
TranslateVersionStr(strVer.get(), &minVer);
@@ -541,69 +544,69 @@ nsPluginDirServiceProvider::GetFile(cons
HKEY keyloc;
FILETIME modTime;
DWORD type;
DWORD index = 0;
DWORD numChars = _MAX_PATH;
DWORD pathlen;
verBlock maxVer;
ClearVersion(&maxVer);
- char curKey[_MAX_PATH] = "software\\Adobe\\Acrobat Reader";
- char path[_MAX_PATH];
+ wchar_t curKey[_MAX_PATH] = L"software\\Adobe\\Acrobat Reader";
+ wchar_t path[_MAX_PATH];
// Add + 8 to prevent buffer overrun when adding \browser
- char newestPath[_MAX_PATH + 8];
+ wchar_t newestPath[_MAX_PATH + 8];
newestPath[0] = 0;
- if (ERROR_SUCCESS != ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, curKey, 0,
+ if (ERROR_SUCCESS != ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, curKey, 0,
KEY_READ, &baseloc)) {
- PL_strcpy(curKey, "software\\Adobe\\Adobe Acrobat");
- if (ERROR_SUCCESS != ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, curKey, 0,
+ wcscpy(curKey, L"software\\Adobe\\Adobe Acrobat");
+ if (ERROR_SUCCESS != ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, curKey, 0,
KEY_READ, &baseloc)) {
return NS_ERROR_FAILURE;
}
}
// We must enumerate through the keys because what if there is
// more than one version?
LONG result = ERROR_SUCCESS;
while (ERROR_SUCCESS == result) {
path[0] = 0;
numChars = _MAX_PATH;
pathlen = sizeof(path);
- result = ::RegEnumKeyEx(baseloc, index, curKey, &numChars, NULL, NULL,
+ result = ::RegEnumKeyExW(baseloc, index, curKey, &numChars, NULL, NULL,
NULL, &modTime);
index++;
if (ERROR_SUCCESS == result) {
verBlock curVer;
- TranslateVersionStr(curKey, &curVer);
- PL_strcat(curKey, "\\InstallPath");
- if (ERROR_SUCCESS == ::RegOpenKeyEx(baseloc, curKey, 0,
+ TranslateVersionStr(NS_ConvertUTF16toUTF8(curKey).get(), &curVer);
+ wcscat(curKey, L"\\InstallPath");
+ if (ERROR_SUCCESS == ::RegOpenKeyExW(baseloc, curKey, 0,
KEY_QUERY_VALUE, &keyloc)) {
// We have a sub key
- if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, NULL, NULL, &type,
+ if (ERROR_SUCCESS == ::RegQueryValueExW(keyloc, NULL, NULL, &type,
(LPBYTE)&path, &pathlen)) {
if (CompareVersion(curVer, maxVer) >= 0 &&
CompareVersion(curVer, minVer) >= 0) {
- PL_strcpy(newestPath, path);
+ wcscpy(newestPath, path);
CopyVersion(&maxVer, &curVer);
}
}
::RegCloseKey(keyloc);
}
}
}
::RegCloseKey(baseloc);
if (newestPath[0] != 0) {
- PL_strcat(newestPath,"\\browser");
- rv = NS_NewNativeLocalFile(nsDependentCString(newestPath), PR_TRUE,
- getter_AddRefs(localFile));
+ wcscat(newestPath, L"\\browser");
+ rv = NS_NewLocalFile(nsDependentString(newestPath), PR_TRUE,
+ getter_AddRefs(localFile));
}
}
if (localFile && NS_SUCCEEDED(rv))
return CallQueryInterface(localFile, _retval);
return rv;
@@ -621,42 +624,42 @@ nsPluginDirServiceProvider::GetPLIDDirec
GetPLIDDirectoriesWithHKEY(HKEY_LOCAL_MACHINE, dirs);
return NS_NewArrayEnumerator(aEnumerator, dirs);
}
nsresult
nsPluginDirServiceProvider::GetPLIDDirectoriesWithHKEY(HKEY aKey, nsCOMArray<nsILocalFile> &aDirs)
{
- char subkey[_MAX_PATH] = "Software\\MozillaPlugins";
+ wchar_t subkey[_MAX_PATH] = L"Software\\MozillaPlugins";
HKEY baseloc;
- if (ERROR_SUCCESS != ::RegOpenKeyEx(aKey, subkey, 0, KEY_READ, &baseloc))
+ if (ERROR_SUCCESS != ::RegOpenKeyExW(aKey, subkey, 0, KEY_READ, &baseloc))
return NS_ERROR_FAILURE;
DWORD index = 0;
DWORD subkeylen = _MAX_PATH;
FILETIME modTime;
- while (ERROR_SUCCESS == ::RegEnumKeyEx(baseloc, index++, subkey, &subkeylen,
+ while (ERROR_SUCCESS == ::RegEnumKeyExW(baseloc, index++, subkey, &subkeylen,
NULL, NULL, NULL, &modTime)) {
subkeylen = _MAX_PATH;
HKEY keyloc;
- if (ERROR_SUCCESS == ::RegOpenKeyEx(baseloc, subkey, 0, KEY_QUERY_VALUE,
+ if (ERROR_SUCCESS == ::RegOpenKeyExW(baseloc, subkey, 0, KEY_QUERY_VALUE,
&keyloc)) {
DWORD type;
- char path[_MAX_PATH];
+ wchar_t path[_MAX_PATH];
DWORD pathlen = sizeof(path);
- if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, "Path", NULL, &type,
+ if (ERROR_SUCCESS == ::RegQueryValueExW(keyloc, L"Path", NULL, &type,
(LPBYTE)&path, &pathlen)) {
nsCOMPtr<nsILocalFile> localFile;
- if (NS_SUCCEEDED(NS_NewNativeLocalFile(nsDependentCString(path),
- PR_TRUE,
- getter_AddRefs(localFile))) &&
+ if (NS_SUCCEEDED(NS_NewLocalFile(nsDependentString(path),
+ PR_TRUE,
+ getter_AddRefs(localFile))) &&
localFile) {
// Some vendors use a path directly to the DLL so chop off
// the filename
PRBool isDir = PR_FALSE;
if (NS_SUCCEEDED(localFile->IsDirectory(&isDir)) && !isDir) {
nsCOMPtr<nsIFile> temp;
localFile->GetParent(getter_AddRefs(temp));
if (temp)
--- a/modules/plugin/base/src/nsPluginHostImpl.cpp
+++ b/modules/plugin/base/src/nsPluginHostImpl.cpp
@@ -4012,36 +4012,36 @@ nsPluginHostImpl::TrySetUpPluginInstance
// couldn't create an XPCOM plugin, try to create wrapper for a
// legacy plugin
if (NS_FAILED(result)) {
if(plugin) {
#ifdef XP_WIN
static BOOL firstJavaPlugin = FALSE;
BOOL restoreOrigDir = FALSE;
- char origDir[_MAX_PATH];
+ PRUnichar origDir[_MAX_PATH];
if (isJavaPlugin && !firstJavaPlugin) {
- DWORD dw = ::GetCurrentDirectory(_MAX_PATH, origDir);
+ DWORD dw = ::GetCurrentDirectoryW(_MAX_PATH, origDir);
NS_ASSERTION(dw <= _MAX_PATH, "Falied to obtain the current directory, which may leads to incorrect class laoding");
nsCOMPtr<nsIFile> binDirectory;
result = NS_GetSpecialDirectory(NS_XPCOM_CURRENT_PROCESS_DIR,
getter_AddRefs(binDirectory));
if (NS_SUCCEEDED(result)) {
- nsCAutoString path;
- binDirectory->GetNativePath(path);
- restoreOrigDir = ::SetCurrentDirectory(path.get());
+ nsAutoString path;
+ binDirectory->GetPath(path);
+ restoreOrigDir = ::SetCurrentDirectoryW(path.get());
}
}
#endif
result = plugin->CreateInstance(NULL, kIPluginInstanceIID, (void **)getter_AddRefs(instance));
#ifdef XP_WIN
if (!firstJavaPlugin && restoreOrigDir) {
- BOOL bCheck = ::SetCurrentDirectory(origDir);
+ BOOL bCheck = ::SetCurrentDirectoryW(origDir);
NS_ASSERTION(bCheck, " Error restoring driectoy");
firstJavaPlugin = TRUE;
}
#endif
}
if (NS_FAILED(result)) {
nsCOMPtr<nsIPlugin> bwPlugin =
--- a/modules/plugin/base/src/nsPluginNativeWindowWin.cpp
+++ b/modules/plugin/base/src/nsPluginNativeWindowWin.cpp
@@ -57,17 +57,17 @@
#include "nsPluginSafety.h"
#include "nsPluginNativeWindow.h"
#include "nsThreadUtils.h"
#include "nsAutoPtr.h"
#include "nsTWeakRef.h"
static NS_DEFINE_CID(kCPluginManagerCID, NS_PLUGINMANAGER_CID); // needed for NS_TRY_SAFE_CALL
-#define NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION "MozillaPluginWindowPropertyAssociation"
+#define NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION L"MozillaPluginWindowPropertyAssociation"
typedef nsTWeakRef<class nsPluginNativeWindowWin> PluginWindowWeakRef;
/**
* PLEvent handling code
*/
class PluginWindowEvent : public nsRunnable {
public:
@@ -198,17 +198,17 @@ NS_IMETHODIMP nsDelayedPopupsEnabledEven
return NS_OK;
}
/**
* New plugin window procedure
*/
static LRESULT CALLBACK PluginWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- nsPluginNativeWindowWin * win = (nsPluginNativeWindowWin *)::GetProp(hWnd, NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION);
+ nsPluginNativeWindowWin * win = (nsPluginNativeWindowWin *)::GetPropW(hWnd, NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION);
if (!win)
return TRUE;
// The DispatchEvent(NS_PLUGIN_ACTIVATE) below can trigger a reentrant focus
// event which might destroy us. Hold a strong ref on the plugin instance
// to prevent that, bug 374229.
nsCOMPtr<nsIPluginInstance> inst;
win->GetPluginInstance(inst);
@@ -521,34 +521,34 @@ nsresult nsPluginNativeWindowWin::Subcla
WNDPROC currentWndProc = (WNDPROC)::GetWindowLong(hWnd, GWL_WNDPROC);
if (PluginWndProc == currentWndProc)
return NS_OK;
mPluginWinProc = SubclassWindow(hWnd, (LONG)PluginWndProc);
if (!mPluginWinProc)
return NS_ERROR_FAILURE;
- nsPluginNativeWindowWin * win = (nsPluginNativeWindowWin *)::GetProp(hWnd, NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION);
+ nsPluginNativeWindowWin * win = (nsPluginNativeWindowWin *)::GetPropW(hWnd, NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION);
NS_ASSERTION(!win || (win == this), "plugin window already has property and this is not us");
- if (!::SetProp(hWnd, NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION, (HANDLE)this))
+ if (!::SetPropW(hWnd, NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION, (HANDLE)this))
return NS_ERROR_FAILURE;
return NS_OK;
}
nsresult nsPluginNativeWindowWin::UndoSubclassAndAssociateWindow()
{
// release plugin instance
SetPluginInstance(nsnull);
// remove window property
HWND hWnd = (HWND)window;
if (IsWindow(hWnd))
- ::RemoveProp(hWnd, NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION);
+ ::RemovePropW(hWnd, NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION);
// restore the original win proc
// but only do this if this were us last time
if (mPluginWinProc) {
WNDPROC currentWndProc = (WNDPROC)::GetWindowLong(hWnd, GWL_WNDPROC);
if (currentWndProc == PluginWndProc)
SubclassWindow(hWnd, (LONG)mPluginWinProc);
}
--- a/modules/plugin/base/src/nsPluginsDirWin.cpp
+++ b/modules/plugin/base/src/nsPluginsDirWin.cpp
@@ -53,35 +53,28 @@
#include "winbase.h"
#include "nsString.h"
///////////////////////////////////////////////////////////////////////////
/* Local helper functions */
-static char* GetKeyValue(char* verbuf, char* key)
+static char* GetKeyValue(wchar_t* verbuf, wchar_t* key)
{
- char *buf = NULL;
+ wchar_t *buf = NULL;
UINT blen;
- ::VerQueryValue(verbuf,
- TEXT(key),
+ ::VerQueryValueW(verbuf,
+ key,
(void **)&buf, &blen);
if(buf != NULL)
{
-#ifdef WINCE
- // On windows CE, the verbuf is wide and the shunt
- // layer can't do much about it. So, here we
- // convert the wide string.
- return PL_strdup(NS_ConvertUTF16toUTF8((PRUnichar*)buf).get());
-#else
- return PL_strdup(buf);
-#endif
+ return strdup(NS_ConvertUTF16toUTF8(buf).get());
}
return nsnull;
}
static PRUint32 CalculateVariantCount(char* mimeTypes)
{
PRUint32 variants = 1;
@@ -211,87 +204,89 @@ nsPluginFile::~nsPluginFile()
* mechanism. Handles platform differences in loading shared libraries.
*/
nsresult nsPluginFile::LoadPlugin(PRLibrary* &outLibrary)
{
// How can we convert to a full path names for using with NSPR?
if (!mPlugin)
return NS_ERROR_NULL_POINTER;
- nsCAutoString temp;
- mPlugin->GetNativePath(temp);
+ nsAutoString temp;
+ mPlugin->GetPath(temp);
- char* index;
- char* pluginFolderPath = PL_strdup(temp.get());
+ PRUnichar* index;
+ PRUnichar* pluginFolderPath = _wcsdup(temp.get());
- index = PL_strrchr(pluginFolderPath, '\\');
+ index = wcsrchr(pluginFolderPath, '\\');
*index = 0;
BOOL restoreOrigDir = FALSE;
- char aOrigDir[MAX_PATH + 1];
- DWORD dwCheck = ::GetCurrentDirectory(sizeof(aOrigDir), aOrigDir);
+ PRUnichar aOrigDir[MAX_PATH + 1];
+ DWORD dwCheck = ::GetCurrentDirectoryW(sizeof(aOrigDir), aOrigDir);
NS_ASSERTION(dwCheck <= MAX_PATH + 1, "Error in Loading plugin");
if (dwCheck <= MAX_PATH + 1)
{
- restoreOrigDir = ::SetCurrentDirectory(pluginFolderPath);
+ restoreOrigDir = ::SetCurrentDirectoryW(pluginFolderPath);
NS_ASSERTION(restoreOrigDir, "Error in Loading plugin");
}
- outLibrary = PR_LoadLibrary(temp.get());
+ outLibrary = PR_LoadLibrary(NS_ConvertUTF16toUTF8(temp).get());
if (restoreOrigDir)
{
- BOOL bCheck = ::SetCurrentDirectory(aOrigDir);
+ BOOL bCheck = ::SetCurrentDirectoryW(aOrigDir);
NS_ASSERTION(bCheck, "Error in Loading plugin");
}
- PL_strfree(pluginFolderPath);
+ free(pluginFolderPath);
return NS_OK;
}
/**
* Obtains all of the information currently available for this plugin.
*/
nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
{
nsresult res = NS_OK;
DWORD zerome, versionsize;
- char* verbuf = nsnull;
+ PRUnichar* verbuf = nsnull;
- const char* path;
+ const PRUnichar* path;
if (!mPlugin)
return NS_ERROR_NULL_POINTER;
- nsCAutoString temp;
- mPlugin->GetNativePath(temp);
+ nsAutoString temp;
+ mPlugin->GetPath(temp);
path = temp.get();
- versionsize = ::GetFileVersionInfoSize((char*)path, &zerome);
+ versionsize = ::GetFileVersionInfoSizeW(path, &zerome);
if (versionsize > 0)
- verbuf = (char *)PR_Malloc(versionsize);
+ verbuf = (wchar_t *)PR_Malloc(versionsize);
if(!verbuf)
return NS_ERROR_OUT_OF_MEMORY;
- if(::GetFileVersionInfo((char*)path, NULL, versionsize, verbuf))
+ if(::GetFileVersionInfoW(path, NULL, versionsize, verbuf))
{
- info.fName = GetKeyValue(verbuf, "\\StringFileInfo\\040904E4\\ProductName");
- info.fDescription = GetKeyValue(verbuf, "\\StringFileInfo\\040904E4\\FileDescription");
+ info.fName = GetKeyValue(verbuf, L"\\StringFileInfo\\040904E4\\ProductName");
+ info.fDescription = GetKeyValue(verbuf, L"\\StringFileInfo\\040904E4\\FileDescription");
- char *mimeType = GetKeyValue(verbuf, "\\StringFileInfo\\040904E4\\MIMEType");
- char *mimeDescription = GetKeyValue(verbuf, "\\StringFileInfo\\040904E4\\FileOpenName");
- char *extensions = GetKeyValue(verbuf, "\\StringFileInfo\\040904E4\\FileExtents");
+ char *mimeType = GetKeyValue(verbuf, L"\\StringFileInfo\\040904E4\\MIMEType");
+ char *mimeDescription = GetKeyValue(verbuf, L"\\StringFileInfo\\040904E4\\FileOpenName");
+ char *extensions = GetKeyValue(verbuf, L"\\StringFileInfo\\040904E4\\FileExtents");
info.fVariantCount = CalculateVariantCount(mimeType);
info.fMimeTypeArray = MakeStringArray(info.fVariantCount, mimeType);
info.fMimeDescriptionArray = MakeStringArray(info.fVariantCount, mimeDescription);
info.fExtensionArray = MakeStringArray(info.fVariantCount, extensions);
- info.fFileName = PL_strdup(path);
+
+ // fFileName is narrow. fix?
+ info.fFileName = PL_strdup(NS_ConvertUTF16toUTF8(path).get());
PL_strfree(mimeType);
PL_strfree(mimeDescription);
PL_strfree(extensions);
}
else
res = NS_ERROR_FAILURE;
--- a/modules/plugin/samples/default/windows/dialogs.cpp
+++ b/modules/plugin/samples/default/windows/dialogs.cpp
@@ -74,60 +74,67 @@ static BOOL onInitDialog(HWND hWnd, HWND
assert(pPlugin != NULL);
if(pPlugin == NULL)
return TRUE;
SetWindowLong(hWnd, DWL_USER, (LONG)pPlugin);
pPlugin->m_hWndDialog = hWnd;
- char szString[512];
- LoadString(hInst, IDS_TITLE, szString, sizeof(szString));
- SetWindowText(hWnd, szString);
+ wchar_t szString[512];
+ LoadStringW(hInst, IDS_TITLE, szString, sizeof(szString));
+ SetWindowTextW(hWnd, szString);
- LoadString(hInst, IDS_INFO, szString, sizeof(szString));
- SetDlgItemText(hWnd, IDC_STATIC_INFO, szString);
+ LoadStringW(hInst, IDS_INFO, szString, sizeof(szString));
+ SetDlgItemTextW(hWnd, IDC_STATIC_INFO, szString);
- SetDlgItemText(hWnd, IDC_STATIC_INFOTYPE, (LPSTR)pPlugin->m_pNPMIMEType);
+ // convert m_pNPMIMEType dougt
+ SetDlgItemTextA(hWnd, IDC_STATIC_INFOTYPE, pPlugin->m_pNPMIMEType);
- LoadString(hInst, IDS_LOCATION, szString, sizeof(szString));
- SetDlgItemText(hWnd, IDC_STATIC_LOCATION, szString);
+ LoadStringW(hInst, IDS_LOCATION, szString, sizeof(szString));
+ SetDlgItemTextW(hWnd, IDC_STATIC_LOCATION, szString);
char contentTypeIsJava = 0;
if (NULL != pPlugin->m_pNPMIMEType) {
contentTypeIsJava = (0 == strcmp("application/x-java-vm",
pPlugin->m_pNPMIMEType)) ? 1 : 0;
}
if(pPlugin->m_szPageURL == NULL || contentTypeIsJava)
- LoadString(hInst, IDS_FINDER_PAGE, szString, sizeof(szString));
+ LoadStringW(hInst, IDS_FINDER_PAGE, szString, sizeof(szString));
else
- strncpy(szString, pPlugin->m_szPageURL,511); // defect #362738
-
+ {
+ MultiByteToWideChar( CP_ACP, 0,
+ pPlugin->m_szPageURL,
+ strlen(pPlugin->m_szPageURL)+1,
+ szString,
+ 511 ); // defect #362738
+ }
+
SetDlgItemTextWrapped(hWnd, IDC_STATIC_URL, szString);
- LoadString(hInst, IDS_QUESTION, szString, sizeof(szString));
- SetDlgItemText(hWnd, IDC_STATIC_QUESTION, szString);
+ LoadStringW(hInst, IDS_QUESTION, szString, sizeof(szString));
+ SetDlgItemTextW(hWnd, IDC_STATIC_QUESTION, szString);
- SetDlgItemText(hWnd, IDC_STATIC_WARNING, "");
+ SetDlgItemTextW(hWnd, IDC_STATIC_WARNING, L"");
if(!pPlugin->m_bOnline)
{
EnableWindow(GetDlgItem(hWnd, IDC_GET_PLUGIN), FALSE);
- LoadString(hInst, IDS_WARNING_OFFLINE, szString, sizeof(szString));
- SetDlgItemText(hWnd, IDC_STATIC_WARNING, szString);
- SetDlgItemText(hWnd, IDC_STATIC_QUESTION, "");
+ LoadStringW(hInst, IDS_WARNING_OFFLINE, szString, sizeof(szString));
+ SetDlgItemTextW(hWnd, IDC_STATIC_WARNING, szString);
+ SetDlgItemTextW(hWnd, IDC_STATIC_QUESTION, L"");
return TRUE;
}
if((!pPlugin->m_bJava) || (!pPlugin->m_bJavaScript) || (!pPlugin->m_bSmartUpdate))
{
- LoadString(hInst, IDS_WARNING_JS, szString, sizeof(szString));
- SetDlgItemText(hWnd, IDC_STATIC_WARNING, szString);
+ LoadStringW(hInst, IDS_WARNING_JS, szString, sizeof(szString));
+ SetDlgItemTextW(hWnd, IDC_STATIC_WARNING, szString);
return TRUE;
}
ShowWindow(GetDlgItem(hWnd, IDC_STATIC_WARNING), SW_HIDE);
RECT rc;
GetWindowRect(GetDlgItem(hWnd, IDC_STATIC_WARNING), &rc);
int iHeight = rc.bottom - rc.top;
--- a/modules/plugin/samples/default/windows/npshell.cpp
+++ b/modules/plugin/samples/default/windows/npshell.cpp
@@ -81,28 +81,28 @@ NPError NP_LOADDS NPP_New(NPMIMEType plu
char * szPageURL = NULL;
char * szFileURL = NULL;
char * szFileExtension = NULL;
char * buf = NULL;
BOOL bHidden = FALSE;
for(int i = 0; i < argc; i++)
{
- if(lstrcmpi(argn[i],"pluginspage") == 0 && argv[i] != NULL)
+ if(strcmpi(argn[i],"pluginspage") == 0 && argv[i] != NULL)
szPageURL = (char *)argv[i];
- else if(lstrcmpi(argn[i],"codebase") == 0 && argv[i] != NULL)
+ else if(strcmpi(argn[i],"codebase") == 0 && argv[i] != NULL)
szPageURL = (char *)argv[i];
- else if(lstrcmpi(argn[i],"pluginurl") == 0 && argv[i] != NULL)
+ else if(strcmpi(argn[i],"pluginurl") == 0 && argv[i] != NULL)
szFileURL = (char *)argv[i];
- else if(lstrcmpi(argn[i],"classid") == 0 && argv[i] != NULL)
+ else if(strcmpi(argn[i],"classid") == 0 && argv[i] != NULL)
szFileURL = (char *)argv[i];
- else if(lstrcmpi(argn[i],"SRC") == 0 && argv[i] != NULL)
+ else if(strcmpi(argn[i],"SRC") == 0 && argv[i] != NULL)
buf = (char *)argv[i];
- else if(lstrcmpi(argn[i],"HIDDEN") == 0 && argv[i] != NULL)
- bHidden = (lstrcmp((char *)argv[i], "TRUE") == 0);
+ else if(strcmpi(argn[i],"HIDDEN") == 0 && argv[i] != NULL)
+ bHidden = (strcmp((char *)argv[i], "TRUE") == 0);
}
/* some post-processing on the filename to attempt to extract the extension: */
if(buf != NULL)
{
buf = strrchr(buf, '.');
if(buf)
szFileExtension = ++buf;
--- a/modules/plugin/samples/default/windows/plugin.cpp
+++ b/modules/plugin/samples/default/windows/plugin.cpp
@@ -46,51 +46,51 @@
#include "dialogs.h"
#include "dbg.h"
#include "nsIServiceManager.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
nsIServiceManager * gServiceManager = NULL;
-static char szNullPluginWindowClassName[] = CLASS_NULL_PLUGIN;
+static wchar_t szNullPluginWindowClassName[] = CLASS_NULL_PLUGIN;
static LRESULT CALLBACK NP_LOADDS PluginWndProc(HWND, UINT, WPARAM, LPARAM);
static char szDefaultPluginFinderURL[] = DEFAULT_PLUGINFINDER_URL;
static char szPageUrlForJavaScript[] = PAGE_URL_FOR_JAVASCRIPT;
static char szPageUrlForJVM[] = JVM_SMARTUPDATE_URL;
//static char szPluginFinderCommandFormatString[] = PLUGINFINDER_COMMAND;
static char szPluginFinderCommandBeginning[] = PLUGINFINDER_COMMAND_BEGINNING;
static char szPluginFinderCommandEnd[] = PLUGINFINDER_COMMAND_END;
BOOL RegisterNullPluginWindowClass()
{
assert(hInst != NULL);
- WNDCLASS wc;
+ WNDCLASSW wc;
memset(&wc, 0, sizeof(wc));
wc.lpfnWndProc = (WNDPROC)PluginWndProc;
wc.cbWndExtra = sizeof(DWORD);
wc.hInstance = hInst;
wc.hIcon = LoadIcon(hInst, IDI_APPLICATION);
wc.hCursor = NULL;
wc.hbrBackground = HBRUSH(COLOR_WINDOW + 1);
wc.lpszClassName = szNullPluginWindowClassName;
- ATOM aRet = RegisterClass(&wc);
+ ATOM aRet = RegisterClassW(&wc);
return (aRet != NULL);
}
void UnregisterNullPluginWindowClass()
{
assert(hInst != NULL);
- UnregisterClass(szNullPluginWindowClassName, hInst);
+ UnregisterClassW(szNullPluginWindowClassName, hInst);
}
/*********************************************/
/* */
/* CPlugin class implementation */
/* */
/*********************************************/
@@ -124,51 +124,51 @@ CPlugin::CPlugin(HINSTANCE hInst,
m_bHidden(bHidden)
{
dbgOut1("CPlugin::CPlugin()");
assert(m_hInst != NULL);
assert(m_pNPInstance != NULL);
if(pluginType && *pluginType)
{
- m_pNPMIMEType = (NPMIMEType)new char[lstrlen((LPSTR)pluginType) + 1];
+ m_pNPMIMEType = (NPMIMEType) new char[strlen(pluginType) + 1];
if(m_pNPMIMEType != NULL)
- lstrcpy((LPSTR)m_pNPMIMEType, pluginType);
+ strcpy(m_pNPMIMEType, pluginType);
}
if(szPageURL && *szPageURL)
{
- m_szPageURL = new char[lstrlen(szPageURL) + 1];
+ m_szPageURL = new char[strlen(szPageURL) + 1];
if(m_szPageURL != NULL)
- lstrcpy(m_szPageURL, szPageURL);
+ strcpy(m_szPageURL, szPageURL);
}
if(szFileURL && *szFileURL)
{
- m_szFileURL = new char[lstrlen(szFileURL) + 1];
+ m_szFileURL = new char[strlen(szFileURL) + 1];
if(m_szFileURL != NULL)
- lstrcpy(m_szFileURL, szFileURL);
+ strcpy(m_szFileURL, szFileURL);
}
if(szFileExtension && *szFileExtension)
{
- m_szFileExtension = new char[lstrlen(szFileExtension) + 1];
+ m_szFileExtension = new char[strlen(szFileExtension) + 1];
if(m_szFileExtension != NULL)
- lstrcpy(m_szFileExtension, szFileExtension);
+ strcpy(m_szFileExtension, szFileExtension);
}
m_hIcon = LoadIcon(m_hInst, MAKEINTRESOURCE(IDI_PLUGICON));
- char szString[1024] = {'\0'};
- LoadString(m_hInst, IDS_CLICK_TO_GET, szString, sizeof(szString));
+ wchar_t szString[1024] = {'\0'};
+ LoadStringW(m_hInst, IDS_CLICK_TO_GET, szString, sizeof(szString));
if(*szString)
{
- m_szCommandMessage = new char[lstrlen(szString) + 1];
+ m_szCommandMessage = new wchar_t[wcslen(szString) + 1];
if(m_szCommandMessage != NULL)
- lstrcpy(m_szCommandMessage, szString);
+ wcscpy(m_szCommandMessage, szString);
}
}
CPlugin::~CPlugin()
{
dbgOut1("CPlugin::~CPlugin()");
if(m_pNPMIMEType != NULL)
@@ -248,18 +248,18 @@ BOOL CPlugin::init(HWND hWndParent)
assert(IsWindow(hWndParent));
if(IsWindow(hWndParent))
m_hWndParent = hWndParent;
RECT rcParent;
GetClientRect(m_hWndParent, &rcParent);
- CreateWindow(szNullPluginWindowClassName,
- "NULL Plugin",
+ CreateWindowW(szNullPluginWindowClassName,
+ L"NULL Plugin",
WS_CHILD,
0,0, rcParent.right, rcParent.bottom,
m_hWndParent,
(HMENU)NULL,
m_hInst,
(LPVOID)this);
assert(m_hWnd != NULL);
@@ -327,72 +327,72 @@ LPSTR CPlugin::createURLString()
{
delete [] m_szURLString;
m_szURLString = NULL;
}
// check if there is file URL first
if(!m_bSmartUpdate && m_szFileURL != NULL)
{
- m_szURLString = new char[lstrlen(m_szFileURL) + 1];
+ m_szURLString = new char[strlen(m_szFileURL) + 1];
if(m_szURLString == NULL)
return NULL;
- lstrcpy(m_szURLString, m_szFileURL);
+ strcpy(m_szURLString, m_szFileURL);
return m_szURLString;
}
// if not get the page URL
char * szAddress = NULL;
char *urlToOpen = NULL;
char contentTypeIsJava = 0;
if (NULL != m_pNPMIMEType) {
contentTypeIsJava = (0 == strcmp("application/x-java-vm",
m_pNPMIMEType)) ? 1 : 0;
}
if(!m_bSmartUpdate && m_szPageURL != NULL && !contentTypeIsJava)
{
- szAddress = new char[lstrlen(m_szPageURL) + 1];
+ szAddress = new char[strlen(m_szPageURL) + 1];
if(szAddress == NULL)
return NULL;
- lstrcpy(szAddress, m_szPageURL);
+ strcpy(szAddress, m_szPageURL);
- m_szURLString = new char[lstrlen(szAddress) + 1 + lstrlen((LPSTR)m_pNPMIMEType) + 1];
+ m_szURLString = new char[strlen(szAddress) + 1 + strlen(m_pNPMIMEType) + 1];
if(m_szURLString == NULL)
return NULL;
// Append the MIME type to the URL
- wsprintf(m_szURLString, "%s?%s", szAddress, (LPSTR)m_pNPMIMEType);
+ sprintf(m_szURLString, "%s?%s", szAddress, (LPSTR)m_pNPMIMEType);
}
else // default
{
if(!m_bSmartUpdate)
{
urlToOpen = szDefaultPluginFinderURL;
if (contentTypeIsJava) {
urlToOpen = szPageUrlForJVM;
}
- szAddress = new char[lstrlen(urlToOpen) + 1];
+ szAddress = new char[strlen(urlToOpen) + 1];
if(szAddress == NULL)
return NULL;
- lstrcpy(szAddress, urlToOpen);
+ strcpy(szAddress, urlToOpen);
- m_szURLString = new char[lstrlen(szAddress) + 10 +
- lstrlen((LPSTR)m_pNPMIMEType) + 1];
+ m_szURLString = new char[strlen(szAddress) + 10 +
+ strlen(m_pNPMIMEType) + 1];
if(m_szURLString == NULL)
return NULL;
// Append the MIME type to the URL
- wsprintf(m_szURLString, "%s?mimetype=%s",
- szAddress, (LPSTR)m_pNPMIMEType);
+ sprintf(m_szURLString, "%s?mimetype=%s",
+ szAddress, m_pNPMIMEType);
}
else
{
urlToOpen = szPageUrlForJavaScript;
if (contentTypeIsJava) {
urlToOpen = szPageUrlForJVM;
}
@@ -404,24 +404,25 @@ LPSTR CPlugin::createURLString()
m_szPageURL[0] = '\0';
}
if (!m_szFileURL) {
m_szFileURL = new char[1];
m_szFileURL[0] = '\0';
}
- m_szURLString = new char[lstrlen(szPluginFinderCommandBeginning) + lstrlen(urlToOpen) + 10 +
- lstrlen((LPSTR)m_pNPMIMEType) + 13 +
- lstrlen((LPSTR)m_szPageURL) + 11 +
- lstrlen((LPSTR)m_szFileURL) +
- lstrlen(szPluginFinderCommandEnd) + 1];
- wsprintf(m_szURLString, "%s%s?mimetype=%s&pluginspage=%s&pluginurl=%s%s",
- szPluginFinderCommandBeginning, urlToOpen,
- (LPSTR)m_pNPMIMEType, m_szPageURL, m_szFileURL, szPluginFinderCommandEnd);
+ m_szURLString = new char[strlen(szPluginFinderCommandBeginning) + strlen(urlToOpen) + 10 +
+ strlen((LPSTR)m_pNPMIMEType) + 13 +
+ strlen((LPSTR)m_szPageURL) + 11 +
+ strlen((LPSTR)m_szFileURL) +
+ strlen(szPluginFinderCommandEnd) + 1];
+ sprintf(m_szURLString, "%s%s?mimetype=%s&pluginspage=%s&pluginurl=%s%s",
+ szPluginFinderCommandBeginning, urlToOpen,
+ m_pNPMIMEType, m_szPageURL, m_szFileURL,
+ szPluginFinderCommandEnd);
}
}
if(szAddress != NULL)
delete [] szAddress;
return m_szURLString;
@@ -507,23 +508,23 @@ void CPlugin::showGetPluginDialog()
void CPlugin::getPlugin()
{
if(m_szCommandMessage != NULL)
{
delete [] m_szCommandMessage;
m_szCommandMessage = NULL;
}
- char szString[1024] = {'\0'};
- LoadString(m_hInst, IDS_CLICK_WHEN_DONE, szString, sizeof(szString));
+ wchar_t szString[1024] = {'\0'};
+ LoadStringW(m_hInst, IDS_CLICK_WHEN_DONE, szString, sizeof(szString));
if(*szString)
{
- m_szCommandMessage = new char[lstrlen(szString) + 1];
+ m_szCommandMessage = new wchar_t[wcslen(szString) + 1];
if(m_szCommandMessage != NULL)
- lstrcpy(m_szCommandMessage, szString);
+ wcscpy(m_szCommandMessage, szString);
}
InvalidateRect(m_hWnd, NULL, TRUE);
UpdateWindow(m_hWnd);
getPluginRegular();
}
@@ -543,30 +544,30 @@ void CPlugin::print(NPPrint * pNPPrint)
return;
}
void CPlugin::URLNotify(const char * szURL)
{
dbgOut2("CPlugin::URLNotify(), URL '%s'", szURL);
NPStream * pStream = NULL;
- char buf[256];
+ wchar_t buf[256];
assert(m_hInst != NULL);
assert(m_pNPInstance != NULL);
- int iSize = LoadString(m_hInst, IDS_GOING2HTML, buf, sizeof(buf));
+ int iSize = LoadStringW(m_hInst, IDS_GOING2HTML, buf, sizeof(buf));
NPError rc = NPN_NewStream(m_pNPInstance, "text/html", "asd_plugin_finder", &pStream);
if (rc != NPERR_NO_ERROR)
return;
- //char buf[] = "<html>\n<body>\n\n<h2 align=center>NPN_NewStream / NPN_Write - This seems to work.</h2>\n\n</body>\n</html>";
+ //wchar_t buf[] = L"<html>\n<body>\n\n<h2 align=center>NPN_NewStream / NPN_Write - This seems to work.</h2>\n\n</body>\n</html>";
- NPN_Write(m_pNPInstance, pStream, iSize, buf);
+ NPN_Write(m_pNPInstance, pStream, iSize, buf); // buf is unicode now.
NPN_DestroyStream(m_pNPInstance, pStream, NPRES_DONE);
}
NPError CPlugin::newStream(NPMIMEType type, NPStream *stream, NPBool seekable, uint16 *stype)
{
if (!m_bWaitingStreamFromPFS)
return NPERR_NO_ERROR;
@@ -589,22 +590,22 @@ NPError CPlugin::destroyStream(NPStream
if (stream == m_PFSStream)
m_PFSStream = NULL;
return NPERR_NO_ERROR;
}
BOOL CPlugin::readyToRefresh()
{
- char szString[1024] = {'\0'};
- LoadString(m_hInst, IDS_CLICK_WHEN_DONE, szString, sizeof(szString));
+ wchar_t szString[1024] = {'\0'};
+ LoadStringW(m_hInst, IDS_CLICK_WHEN_DONE, szString, sizeof(szString));
if(m_szCommandMessage == NULL)
return FALSE;
- return (lstrcmp(m_szCommandMessage, szString) == 0);
+ return (wcscmp(m_szCommandMessage, szString) == 0);
}
//***************************
// Windows message handlers
//***************************
void CPlugin::onCreate(HWND hWnd)
{
m_hWnd = hWnd;
@@ -621,28 +622,28 @@ void CPlugin::onLButtonUp(HWND hWnd, int
void CPlugin::onRButtonUp(HWND hWnd, int x, int y, UINT keyFlags)
{
if(!readyToRefresh())
showGetPluginDialog();
else
NPN_GetURL(m_pNPInstance, "javascript:navigator.plugins.refresh(true)", "_self");
}
-static void DrawCommandMessage(HDC hDC, LPSTR szString, LPRECT lprc)
+static void DrawCommandMessage(HDC hDC, wchar_t* szString, LPRECT lprc)
{
if(szString == NULL)
return;
HFONT hFont = GetStockFont(DEFAULT_GUI_FONT);
if(hFont == NULL)
return;
HFONT hFontOld = SelectFont(hDC, hFont);
SIZE sz;
- GetTextExtentPoint32(hDC, szString, lstrlen(szString), &sz);
+ GetTextExtentPoint32W(hDC, szString, wcslen(szString), &sz);
POINT pt;
pt.x = sz.cx;
pt.y = sz.cy;
LPtoDP(hDC, &pt, 1);
int iY = (lprc->bottom / 2) - ((32) / 2) + 36;
int iX = 0;
@@ -654,17 +655,17 @@ static void DrawCommandMessage(HDC hDC,
RECT rcText;
rcText.left = iX;
rcText.right = rcText.left + pt.x;
rcText.top = iY;
rcText.bottom = rcText.top + pt.y;
int iModeOld = SetBkMode(hDC, TRANSPARENT);
COLORREF crColorOld = SetTextColor(hDC, RGB(0,0,0));
- DrawText(hDC, szString, lstrlen(szString), &rcText, DT_CENTER|DT_VCENTER);
+ DrawTextW(hDC, szString, wcslen(szString), &rcText, DT_CENTER|DT_VCENTER);
SetTextColor(hDC, crColorOld);
SetBkMode(hDC, iModeOld);
SelectFont(hDC, hFontOld);
}
void CPlugin::onPaint(HWND hWnd)
{
RECT rc;
--- a/modules/plugin/samples/default/windows/plugin.h
+++ b/modules/plugin/samples/default/windows/plugin.h
@@ -46,17 +46,17 @@ private:
HINSTANCE m_hInst;
NPP m_pNPInstance;
WORD m_wMode;
HWND m_hWnd;
HWND m_hWndParent;
HICON m_hIcon;
char* m_szURLString;
- char* m_szCommandMessage;
+ wchar_t* m_szCommandMessage;
BOOL m_bWaitingStreamFromPFS;
NPStream* m_PFSStream;
public:
BOOL m_bHidden;
NPMIMEType m_pNPMIMEType;
LPSTR m_szPageURL; // Location of plug-in HTML page
LPSTR m_szFileURL; // Location of plug-in JAR file
@@ -113,24 +113,24 @@ public:
#define PAGE_URL_FOR_JAVASCRIPT "http://plugindoc.mozdev.org/winmime.html"
#define PLUGINFINDER_COMMAND_BEGINNING ""
#define PLUGINFINDER_COMMAND_END ""
#define DEFAULT_PLUGINFINDER_URL "http://plugindoc.mozdev.org/winmime.html"
#define JVM_SMARTUPDATE_URL "http://java.com/download"
#ifdef WIN32
-#define REGISTRY_PLACE "Software\\Netscape\\Netscape Navigator\\Default Plugin"
+#define REGISTRY_PLACE L"Software\\Netscape\\Netscape Navigator\\Default Plugin"
#else
#define GWL_USERDATA 0
#define COLOR_3DSHADOW COLOR_BTNFACE
#define COLOR_3DLIGHT COLOR_BTNHIGHLIGHT
#define COLOR_3DDKSHADOW COLOR_BTNSHADOW
#endif
-#define CLASS_NULL_PLUGIN "NullPluginClass"
+#define CLASS_NULL_PLUGIN L"NullPluginClass"
BOOL RegisterNullPluginWindowClass();
void UnregisterNullPluginWindowClass();
extern HINSTANCE hInst;
#endif // __PLUGIN_HPP__
--- a/modules/plugin/samples/default/windows/utils.cpp
+++ b/modules/plugin/samples/default/windows/utils.cpp
@@ -40,132 +40,139 @@
#include "plugin.h"
// open the registry, create if necessary
HKEY openRegistry()
{
HKEY phkResult;
- if(RegCreateKey(HKEY_CURRENT_USER, REGISTRY_PLACE, &phkResult) != ERROR_SUCCESS)
- MessageBox(0, "Error creating Default Plugin registry key", "Default Plugin", MB_OK);
+ if(RegCreateKeyW(HKEY_CURRENT_USER, REGISTRY_PLACE, &phkResult) != ERROR_SUCCESS)
+ MessageBoxW(0, L"Error creating Default Plugin registry key", L"Default Plugin", MB_OK);
return phkResult;
}
// return TRUE if we've never seen this MIME type before
BOOL IsNewMimeType(LPSTR mime)
{
HKEY hkey = openRegistry();
DWORD dwType, keysize = 512;
- char keybuf[512];
+ wchar_t keybuf[512];
+ wchar_t wideMime[64];
- if(RegQueryValueEx(hkey, mime, 0, &dwType, (LPBYTE) &keybuf, &keysize) == ERROR_SUCCESS)
+ MultiByteToWideChar(CP_ACP, 0,
+ mime,
+ strlen(mime) + 1,
+ wideMime,
+ 64);
+
+ if(RegQueryValueExW(hkey, wideMime, 0, &dwType, (LPBYTE) &keybuf, &keysize) == ERROR_SUCCESS)
{
// key exists, must have already been here...
return FALSE;
}
else
{
- if(RegSetValueEx(hkey, mime, 0, REG_SZ, (LPBYTE) "(none)", 7) != ERROR_SUCCESS)
- MessageBox(0, "Error adding MIME type value", "Default Plugin", MB_OK);
+ if(RegSetValueExW(hkey, wideMime, 0, REG_SZ, (LPBYTE) L"(none)", 7) != ERROR_SUCCESS)
+ MessageBoxW(0, L"Error adding MIME type value", L"Default Plugin", MB_OK);
return TRUE;
}
}
// string length in pixels for the specific window (selected font)
-static int getWindowStringLength(HWND hWnd, LPSTR lpsz)
+static int getWindowStringLength(HWND hWnd, wchar_t* lpsz)
{
SIZE sz;
HDC hDC = GetDC(hWnd);
HFONT hWindowFont = GetWindowFont(hWnd);
HFONT hFontOld = SelectFont(hDC, hWindowFont);
- GetTextExtentPoint32(hDC, lpsz, lstrlen(lpsz), &sz);
+ GetTextExtentPoint32W(hDC, lpsz, wcslen(lpsz), &sz);
POINT pt;
pt.x = sz.cx;
pt.y = sz.cy;
LPtoDP(hDC, &pt, 1);
SelectFont(hDC, hFontOld);
ReleaseDC(hWnd, hDC);
return (int)pt.x;
}
-/****************************************************************/
-/* */
-/* void SetDlgItemTextWrapped(HWND hWnd, int iID, LPSTR szText) */
-/* */
-/* helper to wrap long lines in a static control, which do not */
-/* wrap automatically if they do not have space characters */
-/* */
-/****************************************************************/
-void SetDlgItemTextWrapped(HWND hWnd, int iID, LPSTR szText)
+/*******************************************************************/
+/* */
+/* void SetDlgItemTextWrapped(HWND hWnd, int iID, wchar_t* szText) */
+/* */
+/* helper to wrap long lines in a static control, which do not */
+/* wrap automatically if they do not have space characters */
+/* */
+/*******************************************************************/
+void SetDlgItemTextWrapped(HWND hWnd, int iID, wchar_t* szText)
{
HWND hWndStatic = GetDlgItem(hWnd, iID);
- if((szText == NULL) || (lstrlen(szText) == 0))
+ if((szText == NULL) || (wcslen(szText) == 0))
{
- SetDlgItemText(hWnd, iID, "");
+ SetDlgItemTextW(hWnd, iID, L"");
return;
}
RECT rc;
GetClientRect(hWndStatic, &rc);
int iStaticLength = rc.right - rc.left;
int iStringLength = getWindowStringLength(hWndStatic, szText);
if(iStringLength <= iStaticLength)
{
- SetDlgItemText(hWnd, iID, szText);
+ SetDlgItemTextW(hWnd, iID, szText);
return;
}
int iBreaks = iStringLength/iStaticLength;
if(iBreaks <= 0)
return;
- char * pBuf = new char[iStringLength + iBreaks + 1];
+ wchar_t * pBuf = new wchar_t[iStringLength + iBreaks + 1];
if(pBuf == NULL)
return;
- lstrcpy(pBuf, "");
+ wcscpy(pBuf, L"");
int iStart = 0;
int iLines = 0;
for(int i = 0; i < iStringLength; i++)
{
- char * sz = &szText[iStart];
+ wchar_t* sz = &szText[iStart];
int iIndex = i - iStart;
- char ch = sz[iIndex + 1];
+ wchar_t ch = sz[iIndex + 1];
sz[iIndex + 1] = '\0';
int iLength = getWindowStringLength(hWndStatic, sz);
if(iLength < iStaticLength)
{
sz[iIndex + 1] = ch;
if(iLines == iBreaks)
{
- lstrcat(pBuf, sz);
+ wcscat(pBuf, sz);
break;
}
continue;
}
sz[iIndex + 1] = ch; // restore zeroed element
i--; // go one step back
ch = sz[iIndex];
sz[iIndex] = '\0'; // terminate string one char shorter
- lstrcat(pBuf, sz); // append the string
- lstrcat(pBuf, " "); // append space character for successful wrapping
+ wcscat(pBuf, sz); // append the string
+ wcscat(pBuf, L" "); // append space character for successful wrapping
- iStart += lstrlen(sz);// shift new start position
+ iStart += wcslen(sz); // shift new start position
sz[iIndex] = ch; // restore zeroed element
iLines++; // count lines
}
- SetDlgItemText(hWnd, iID, pBuf);
+ SetDlgItemTextW(hWnd, iID, pBuf);
delete [] pBuf;
}
--- a/modules/plugin/samples/default/windows/utils.h
+++ b/modules/plugin/samples/default/windows/utils.h
@@ -35,11 +35,11 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef __UTILS_H__
#define __UTILS_H__
HKEY openRegistry();
BOOL IsNewMimeType(LPSTR szMimeType);
-void SetDlgItemTextWrapped(HWND hWnd, int iID, LPSTR szText);
+void SetDlgItemTextWrapped(HWND hWnd, int iID, wchar_t* szText);
#endif // __UTILS_H__
--- a/modules/plugin/tools/sdk/samples/basic/windows/plugin.cpp
+++ b/modules/plugin/tools/sdk/samples/basic/windows/plugin.cpp
@@ -141,21 +141,21 @@ static LRESULT CALLBACK PluginWinProc(HW
RECT rc;
GetClientRect(hWnd, &rc);
FrameRect(hdc, &rc, GetStockBrush(BLACK_BRUSH));
// get our plugin instance object and ask it for the version string
nsPluginInstance *plugin = (nsPluginInstance *)GetWindowLong(hWnd, GWL_USERDATA);
if (plugin) {
const char * string = plugin->getVersion();
- DrawText(hdc, string, strlen(string), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
+ DrawTextA(hdc, string, strlen(string), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
}
else {
char string[] = "Error occured";
- DrawText(hdc, string, strlen(string), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
+ DrawTextA(hdc, string, strlen(string), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
}
EndPaint(hWnd, &ps);
}
break;
default:
break;
}
--- a/modules/plugin/tools/sdk/samples/scriptable/windows/plugin.cpp
+++ b/modules/plugin/tools/sdk/samples/scriptable/windows/plugin.cpp
@@ -215,20 +215,20 @@ static LRESULT CALLBACK PluginWinProc(HW
HDC hdc = BeginPaint(hWnd, &ps);
RECT rc;
GetClientRect(hWnd, &rc);
FrameRect(hdc, &rc, GetStockBrush(BLACK_BRUSH));
// get our plugin instance object and ask it for the version string
nsPluginInstance *plugin = (nsPluginInstance *)GetWindowLong(hWnd, GWL_USERDATA);
if (plugin)
- DrawText(hdc, plugin->mString, strlen(plugin->mString), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
+ DrawTextA(hdc, plugin->mString, strlen(plugin->mString), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
else {
char string[] = "Error occured";
- DrawText(hdc, string, strlen(string), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
+ DrawTextA(hdc, string, strlen(string), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
}
EndPaint(hWnd, &ps);
}
break;
default:
break;
}
--- a/rdf/datasource/src/nsFileSystemDataSource.cpp
+++ b/rdf/datasource/src/nsFileSystemDataSource.cpp
@@ -923,24 +923,25 @@ FileSystemDataSource::GetVolumeList(nsIS
volumes->AppendElement(vol);
}
#endif
#if defined (XP_WIN) && !defined (WINCE)
PRInt32 driveType;
- char drive[32];
+ PRUnichar drive[32];
PRInt32 volNum;
char *url;
for (volNum = 0; volNum < 26; volNum++)
{
- sprintf(drive, "%c:\\", volNum + 'A');
- driveType = GetDriveType(drive);
+ swprintf( drive, L"%c:\\", volNum + (PRUnichar)'A');
+
+ driveType = GetDriveTypeW(drive);
if (driveType != DRIVE_UNKNOWN && driveType != DRIVE_NO_ROOT_DIR)
{
if (nsnull != (url = PR_smprintf("file:///%c|/", volNum + 'A')))
{
rv = mRDFService->GetResource(nsDependentCString(url),
getter_AddRefs(vol));
PR_Free(url);
--- a/toolkit/components/startup/src/nsUserInfoWin.cpp
+++ b/toolkit/components/startup/src/nsUserInfoWin.cpp
@@ -53,24 +53,23 @@ nsUserInfo::~nsUserInfo()
NS_IMPL_ISUPPORTS1(nsUserInfo,nsIUserInfo)
NS_IMETHODIMP
nsUserInfo::GetUsername(char **aUsername)
{
*aUsername = nsnull;
- TCHAR username[256];
+ PRUnichar username[256];
DWORD size = 256;
- if (!GetUserName(username, &size))
+ if (!GetUserNameW(username, &size))
return NS_ERROR_FAILURE;
-
- *aUsername = nsCRT::strdup(username);
-
+
+ *aUsername = ToNewUTF8String(nsDependentString(username));
if (*aUsername) return NS_OK;
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsUserInfo::GetFullname(PRUnichar **aFullname)
{
--- a/uriloader/exthandler/win/nsMIMEInfoWin.cpp
+++ b/uriloader/exthandler/win/nsMIMEInfoWin.cpp
@@ -261,46 +261,48 @@ nsMIMEInfoWin::LoadUriInternal(nsIURI *
const PRUint32 maxSafeURL(2048);
if (urlSpec.Length() > maxSafeURL)
return NS_ERROR_FAILURE;
LPITEMIDLIST pidl;
SFGAOF sfgao;
// Bug 394974
- HMODULE hDll = ::LoadLibrary("shell32.dll");
+ HMODULE hDll = ::LoadLibraryW(L"shell32.dll");
MySHParseDisplayName pMySHParseDisplayName = NULL;
// Version 6.0 and higher
if (pMySHParseDisplayName =
(MySHParseDisplayName)::GetProcAddress(hDll,
"SHParseDisplayName")) {
if (SUCCEEDED(pMySHParseDisplayName(NS_ConvertUTF8toUTF16(urlSpec).get(),
NULL, &pidl, 0, &sfgao))) {
- static const char cmdVerb[] = "open";
- SHELLEXECUTEINFO sinfo;
+ static const PRUnichar cmdVerb[] = L"open";
+ SHELLEXECUTEINFOW sinfo;
memset(&sinfo, 0, sizeof(SHELLEXECUTEINFO));
sinfo.cbSize = sizeof(SHELLEXECUTEINFO);
sinfo.fMask = SEE_MASK_FLAG_DDEWAIT |
SEE_MASK_FLAG_NO_UI |
SEE_MASK_INVOKEIDLIST;
sinfo.hwnd = NULL;
- sinfo.lpVerb = (LPCSTR)&cmdVerb;
+ sinfo.lpVerb = (LPWSTR)&cmdVerb;
sinfo.nShow = SW_SHOWNORMAL;
sinfo.lpIDList = pidl;
- BOOL result = ShellExecuteEx(&sinfo);
+ BOOL result = ShellExecuteExW(&sinfo);
CoTaskMemFree(pidl);
if (!result || ((int)sinfo.hInstApp) < 32)
rv = NS_ERROR_FAILURE;
}
} else {
// Version of shell32.dll < 6.0
- LONG r = (LONG) ::ShellExecute(NULL, "open", urlSpec.get(), NULL, NULL,
+ LONG r = (LONG) ::ShellExecuteW(NULL, L"open",
+ NS_ConvertUTF8toUTF16(urlSpec).get(),
+ NULL, NULL,
SW_SHOWNORMAL);
if (r < 32)
rv = NS_ERROR_FAILURE;
}
if (hDll)
::FreeLibrary(hDll);
}
--- a/uriloader/exthandler/win/nsOSHelperAppService.cpp
+++ b/uriloader/exthandler/win/nsOSHelperAppService.cpp
@@ -140,21 +140,21 @@ 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)
{
HKEY hKey;
- LONG err = ::RegOpenKeyEx(HKEY_CLASSES_ROOT, aProtocolScheme, 0,
+ LONG err = ::RegOpenKeyExA(HKEY_CLASSES_ROOT, aProtocolScheme, 0,
KEY_QUERY_VALUE, &hKey);
if (err == ERROR_SUCCESS)
{
- err = ::RegQueryValueEx(hKey, "URL Protocol", NULL, NULL, NULL, NULL);
+ err = ::RegQueryValueExW(hKey, L"URL Protocol", NULL, NULL, NULL, NULL);
*aHandlerExists = (err == ERROR_SUCCESS);
// close the key
::RegCloseKey(hKey);
}
}
return NS_OK;
}
--- a/widget/src/windows/nsAppShell.cpp
+++ b/widget/src/windows/nsAppShell.cpp
@@ -88,37 +88,37 @@ nsAppShell::~nsAppShell()
SendMessage(mEventWnd, WM_CLOSE, 0, 0);
}
}
nsresult
nsAppShell::Init()
{
if (!sMsgId)
- sMsgId = RegisterWindowMessage("nsAppShell:EventID");
+ sMsgId = RegisterWindowMessageW(L"nsAppShell:EventID");
- WNDCLASS wc;
+ WNDCLASSW wc;
HINSTANCE module = GetModuleHandle(NULL);
- const char *const kWindowClass = "nsAppShell:EventWindowClass";
- if (!GetClassInfo(module, kWindowClass, &wc)) {
+ const PRUnichar *const kWindowClass = L"nsAppShell:EventWindowClass";
+ if (!GetClassInfoW(module, kWindowClass, &wc)) {
wc.style = 0;
wc.lpfnWndProc = EventWindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = module;
wc.hIcon = NULL;
wc.hCursor = NULL;
wc.hbrBackground = (HBRUSH) NULL;
- wc.lpszMenuName = (LPCSTR) NULL;
+ wc.lpszMenuName = (LPCWSTR) NULL;
wc.lpszClassName = kWindowClass;
- RegisterClass(&wc);
+ RegisterClassW(&wc);
}
- mEventWnd = CreateWindow(kWindowClass, "nsAppShell:EventWindow",
+ mEventWnd = CreateWindowW(kWindowClass, L"nsAppShell:EventWindow",
0, 0, 0, 10, 10, NULL, NULL, module, NULL);
NS_ENSURE_STATE(mEventWnd);
return nsBaseAppShell::Init();
}
void
nsAppShell::ScheduleNativeEventCallback()
--- a/widget/src/windows/nsBidiKeyboard.cpp
+++ b/widget/src/windows/nsBidiKeyboard.cpp
@@ -35,16 +35,17 @@
* 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 ***** */
#include <stdio.h>
#include "nsBidiKeyboard.h"
#include "prmem.h"
+#include <tchar.h>
NS_IMPL_ISUPPORTS1(nsBidiKeyboard, nsIBidiKeyboard)
nsBidiKeyboard::nsBidiKeyboard() : nsIBidiKeyboard()
{
mInitialized = PR_FALSE;
mHaveBidiKeyboards = PR_FALSE;
mLTRKeyboard[0] = '\0';
@@ -58,18 +59,18 @@ nsBidiKeyboard::~nsBidiKeyboard()
NS_IMETHODIMP nsBidiKeyboard::SetLangFromBidiLevel(PRUint8 aLevel)
{
nsresult result = SetupBidiKeyboards();
if (NS_FAILED(result))
return result;
// call LoadKeyboardLayout() only if the target keyboard layout is different from the current
- char currentLocaleName[KL_NAMELENGTH];
- strncpy(currentLocaleName, (aLevel & 1) ? mRTLKeyboard : mLTRKeyboard, KL_NAMELENGTH);
+ PRUnichar currentLocaleName[KL_NAMELENGTH];
+ wcsncpy(currentLocaleName, (aLevel & 1) ? mRTLKeyboard : mLTRKeyboard, KL_NAMELENGTH);
currentLocaleName[KL_NAMELENGTH-1] = '\0'; // null terminate
NS_ASSERTION(*currentLocaleName,
"currentLocaleName has string length == 0");
#if 0
/* This implementation of automatic keyboard layout switching is too buggy to be useful
and the feature itself is inconsistent with Windows. See Bug 162242 */
@@ -91,53 +92,53 @@ NS_IMETHODIMP nsBidiKeyboard::IsLangRTL(
if (NS_FAILED(result))
return result;
HKL currentLocale;
currentLocale = ::GetKeyboardLayout(0);
*aIsRTL = IsRTLLanguage(currentLocale);
- if (!::GetKeyboardLayoutName(mCurrentLocaleName))
+ if (!::GetKeyboardLayoutNameW(mCurrentLocaleName))
return NS_ERROR_FAILURE;
NS_ASSERTION(*mCurrentLocaleName,
"GetKeyboardLayoutName return string length == 0");
- NS_ASSERTION((strlen(mCurrentLocaleName) < KL_NAMELENGTH),
+ NS_ASSERTION((wcslen(mCurrentLocaleName) < KL_NAMELENGTH),
"GetKeyboardLayoutName return string length >= KL_NAMELENGTH");
// The language set by the user overrides the default language for that direction
if (*aIsRTL) {
- strncpy(mRTLKeyboard, mCurrentLocaleName, KL_NAMELENGTH);
+ wcsncpy(mRTLKeyboard, mCurrentLocaleName, KL_NAMELENGTH);
mRTLKeyboard[KL_NAMELENGTH-1] = '\0'; // null terminate
} else {
- strncpy(mLTRKeyboard, mCurrentLocaleName, KL_NAMELENGTH);
+ wcsncpy(mLTRKeyboard, mCurrentLocaleName, KL_NAMELENGTH);
mLTRKeyboard[KL_NAMELENGTH-1] = '\0'; // null terminate
}
- NS_ASSERTION((strlen(mRTLKeyboard) < KL_NAMELENGTH),
+ NS_ASSERTION((wcslen(mRTLKeyboard) < KL_NAMELENGTH),
"mLTRKeyboard has string length >= KL_NAMELENGTH");
- NS_ASSERTION((strlen(mLTRKeyboard) < KL_NAMELENGTH),
+ NS_ASSERTION((wcslen(mLTRKeyboard) < KL_NAMELENGTH),
"mRTLKeyboard has string length >= KL_NAMELENGTH");
return NS_OK;
}
// Get the list of keyboard layouts available in the system
// Set mLTRKeyboard to the first LTR keyboard in the list and mRTLKeyboard to the first RTL keyboard in the list
// These defaults will be used unless the user explicitly sets something else.
nsresult nsBidiKeyboard::SetupBidiKeyboards()
{
if (mInitialized)
return mHaveBidiKeyboards ? NS_OK : NS_ERROR_FAILURE;
int keyboards;
HKL far* buf;
HKL locale;
- char localeName[KL_NAMELENGTH];
+ PRUnichar localeName[KL_NAMELENGTH];
PRBool isLTRKeyboardSet = PR_FALSE;
PRBool isRTLKeyboardSet = PR_FALSE;
// GetKeyboardLayoutList with 0 as first parameter returns the number of keyboard layouts available
keyboards = ::GetKeyboardLayoutList(0, nsnull);
if (!keyboards)
return NS_ERROR_FAILURE;
@@ -151,21 +152,21 @@ nsresult nsBidiKeyboard::SetupBidiKeyboa
PR_Free(buf);
return NS_ERROR_UNEXPECTED;
}
// Go through the list and pick a default LTR and RTL keyboard layout
while (keyboards--) {
locale = buf[keyboards];
if (IsRTLLanguage(locale)) {
- sprintf(mRTLKeyboard, "%.*x", KL_NAMELENGTH - 1, LANGIDFROMLCID(locale));
+ swprintf(mRTLKeyboard, L"%.*x", KL_NAMELENGTH - 1, LANGIDFROMLCID(locale));
isRTLKeyboardSet = PR_TRUE;
}
else {
- sprintf(mLTRKeyboard, "%.*x", KL_NAMELENGTH - 1, LANGIDFROMLCID(locale));
+ swprintf( mLTRKeyboard, L"%.*x", KL_NAMELENGTH - 1, LANGIDFROMLCID(locale));
isLTRKeyboardSet = PR_TRUE;
}
}
PR_Free(buf);
mInitialized = PR_TRUE;
// If there is not at least one keyboard of each directionality, Bidi
// keyboard functionality will be disabled.
@@ -173,30 +174,30 @@ nsresult nsBidiKeyboard::SetupBidiKeyboa
if (!mHaveBidiKeyboards)
return NS_ERROR_FAILURE;
// Get the current keyboard layout and use it for either mRTLKeyboard or
// mLTRKeyboard as appropriate. If the user has many keyboard layouts
// installed this prevents us from arbitrarily resetting the current
// layout (bug 80274)
locale = ::GetKeyboardLayout(0);
- if (!::GetKeyboardLayoutName(localeName))
+ if (!::GetKeyboardLayoutNameW(localeName))
return NS_ERROR_FAILURE;
NS_ASSERTION(*localeName,
"GetKeyboardLayoutName return string length == 0");
- NS_ASSERTION((strlen(localeName) < KL_NAMELENGTH),
+ NS_ASSERTION((wcslen(localeName) < KL_NAMELENGTH),
"GetKeyboardLayout return string length >= KL_NAMELENGTH");
if (IsRTLLanguage(locale)) {
- strncpy(mRTLKeyboard, localeName, KL_NAMELENGTH);
+ swprintf(mRTLKeyboard, localeName, KL_NAMELENGTH);
mRTLKeyboard[KL_NAMELENGTH-1] = '\0'; // null terminate
}
else {
- strncpy(mLTRKeyboard, localeName, KL_NAMELENGTH);
+ swprintf( mLTRKeyboard, localeName, KL_NAMELENGTH);
mLTRKeyboard[KL_NAMELENGTH-1] = '\0'; // null terminate
}
NS_ASSERTION(*mRTLKeyboard,
"mLTRKeyboard has string length == 0");
NS_ASSERTION(*mLTRKeyboard,
"mLTRKeyboard has string length == 0");
--- a/widget/src/windows/nsBidiKeyboard.h
+++ b/widget/src/windows/nsBidiKeyboard.h
@@ -53,15 +53,15 @@ public:
protected:
nsresult SetupBidiKeyboards();
PRBool IsRTLLanguage(HKL aLocale);
PRPackedBool mInitialized;
PRPackedBool mHaveBidiKeyboards;
- char mLTRKeyboard[KL_NAMELENGTH];
- char mRTLKeyboard[KL_NAMELENGTH];
- char mCurrentLocaleName[KL_NAMELENGTH];
+ PRUnichar mLTRKeyboard[KL_NAMELENGTH];
+ PRUnichar mRTLKeyboard[KL_NAMELENGTH];
+ PRUnichar mCurrentLocaleName[KL_NAMELENGTH];
};
#endif // __nsBidiKeyboard
--- a/widget/src/windows/nsClipboard.cpp
+++ b/widget/src/windows/nsClipboard.cpp
@@ -65,17 +65,17 @@
#include "nsWidgetsCID.h"
#include "nsCRT.h"
#include "nsNetUtil.h"
#include "nsIImage.h"
// oddly, this isn't in the MSVC headers anywhere.
-UINT nsClipboard::CF_HTML = ::RegisterClipboardFormat("HTML Format");
+UINT nsClipboard::CF_HTML = ::RegisterClipboardFormatW(L"HTML Format");
//-------------------------------------------------------------------------
//
// nsClipboard constructor
//
//-------------------------------------------------------------------------
nsClipboard::nsClipboard() : nsBaseClipboard()
@@ -106,17 +106,19 @@ UINT nsClipboard::GetFormat(const char*
format = CF_DIB;
else if (strcmp(aMimeStr, kFileMime) == 0 ||
strcmp(aMimeStr, kFilePromiseMime) == 0)
format = CF_HDROP;
#endif
else if (strcmp(aMimeStr, kNativeHTMLMime) == 0)
format = CF_HTML;
else
- format = ::RegisterClipboardFormat(aMimeStr);
+ format = ::RegisterClipboardFormatW(NS_ConvertASCIItoUTF16(aMimeStr).get());
+
+
return format;
}
//-------------------------------------------------------------------------
nsresult nsClipboard::CreateNativeDataObject(nsITransferable * aTransferable, IDataObject ** aDataObj, nsIURI * uri)
{
if (nsnull == aTransferable) {
@@ -311,17 +313,17 @@ nsresult nsClipboard::GetGlobalData(HGLO
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
// Display the string.
- MessageBox( NULL, (const char *)lpMsgBuf, "GetLastError", MB_OK|MB_ICONINFORMATION );
+ MessageBoxW( NULL, (LPCWSTR)lpMsgBuf, L"GetLastError", MB_OK|MB_ICONINFORMATION );
// Free the buffer.
LocalFree( lpMsgBuf );
}
return result;
}
--- a/widget/src/windows/nsDataObj.h
+++ b/widget/src/windows/nsDataObj.h
@@ -77,31 +77,31 @@ IAsyncOperation : public IUnknown
#endif // __IAsyncOperation_INTERFACE_DEFINED__
/*
* CFSTR_SHELLURL is deprecated and doesn't have a Unicode version.
* Therefore we are using CFSTR_INETURL instead of CFSTR_SHELLURL.
* See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/programmersguide/shell_basics/shell_basics_programming/transferring/clipboard.asp
*/
#ifndef CFSTR_INETURLA
-#define CFSTR_INETURLA "UniformResourceLocator"
+#define CFSTR_INETURLA L"UniformResourceLocator"
#endif
#ifndef CFSTR_INETURLW
-#define CFSTR_INETURLW "UniformResourceLocatorW"
+#define CFSTR_INETURLW L"UniformResourceLocatorW"
#endif
// For support of MinGW w32api v2.4.
// When the next version of w32api is released with shlobj.h rev 1.35
// http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/winsup/w32api/include/shlobj.h?cvsroot=src
// then that can be made the base required version and this code should be removed.
#ifndef CFSTR_FILEDESCRIPTORA
-# define CFSTR_FILEDESCRIPTORA "FileGroupDescriptor"
+# define CFSTR_FILEDESCRIPTORA L"FileGroupDescriptor"
#endif
#ifndef CFSTR_FILEDESCRIPTORW
-# define CFSTR_FILEDESCRIPTORW "FileGroupDescriptorW"
+# define CFSTR_FILEDESCRIPTORW L"FileGroupDescriptorW"
#endif
#ifdef __MINGW32__
# include <w32api.h>
# if __W32API_MAJOR_VERSION < 3 || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION == 0)
# ifndef FILEGROUPDESCRIPTORA
# define FILEGROUPDESCRIPTORA FILEGROUPDESCRIPTOR
# endif
--- a/widget/src/windows/nsFilePicker.cpp
+++ b/widget/src/windows/nsFilePicker.cpp
@@ -275,20 +275,20 @@ NS_IMETHODIMP nsFilePicker::ShowW(PRInt1
}
}
else {
NS_ASSERTION(0, "unsupported mode");
}
#ifndef WINCE
}
catch(...) {
- MessageBox(ofn.hwndOwner,
- 0,
- "The filepicker was unexpectedly closed by Windows.",
- MB_ICONERROR);
+ MessageBoxW(ofn.hwndOwner,
+ 0,
+ L"The filepicker was unexpectedly closed by Windows.",
+ MB_ICONERROR);
result = PR_FALSE;
}
#endif
if (result == PR_TRUE) {
// Remember what filter type the user selected
mSelectedType = (PRInt16)ofn.nFilterIndex;
--- a/widget/src/windows/nsLookAndFeel.cpp
+++ b/widget/src/windows/nsLookAndFeel.cpp
@@ -51,17 +51,17 @@ typedef HRESULT (WINAPI*GetThemeColorPtr
int iStateId, int iPropId, OUT COLORREF* pFont);
typedef BOOL (WINAPI*IsAppThemedPtr)(VOID);
static OpenThemeDataPtr openTheme = NULL;
static CloseThemeDataPtr closeTheme = NULL;
static GetThemeColorPtr getThemeColor = NULL;
static IsAppThemedPtr isAppThemed = NULL;
-static const char kThemeLibraryName[] = "uxtheme.dll";
+static const PRUnichar kThemeLibraryName[] = L"uxtheme.dll";
static HINSTANCE gThemeDLLInst = NULL;
static HANDLE gMenuTheme = NULL;
#define MENU_POPUPITEM 14
#define MPI_NORMAL 1
#define MPI_HOT 2
#define MPI_DISABLED 3
@@ -100,23 +100,23 @@ static PRInt32 GetSystemParam(long flag,
DWORD value;
return ::SystemParametersInfo(flag, 0, &value, 0) ? value : def;
#endif
}
nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel()
{
#ifndef WINCE
- gShell32DLLInst = LoadLibrary("Shell32.dll");
+ gShell32DLLInst = LoadLibraryW(L"Shell32.dll");
if (gShell32DLLInst)
{
gSHAppBarMessage = (SHAppBarMessagePtr) GetProcAddress(gShell32DLLInst,
"SHAppBarMessage");
}
- gThemeDLLInst = LoadLibrary(kThemeLibraryName);
+ gThemeDLLInst = LoadLibraryW(kThemeLibraryName);
if(gThemeDLLInst)
{
openTheme = (OpenThemeDataPtr)GetProcAddress(gThemeDLLInst, "OpenThemeData");
closeTheme = (CloseThemeDataPtr)GetProcAddress(gThemeDLLInst, "CloseThemeData");
getThemeColor = (GetThemeColorPtr)GetProcAddress(gThemeDLLInst, "GetThemeColor");
isAppThemed = (IsAppThemedPtr)GetProcAddress(gThemeDLLInst, "IsAppThemed");
gMenuTheme = openTheme(NULL, L"Menu");
}
@@ -499,17 +499,17 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(c
aMetric = 3;
break;
#ifndef WINCE
case eMetric_AlertNotificationOrigin:
aMetric = 0;
if (gSHAppBarMessage)
{
// Get task bar window handle
- HWND shellWindow = FindWindow("Shell_TrayWnd", NULL);
+ HWND shellWindow = FindWindowW(L"Shell_TrayWnd", NULL);
if (shellWindow != NULL)
{
// Determine position
APPBARDATA appBarData;
appBarData.hWnd = shellWindow;
appBarData.cbSize = sizeof(appBarData);
if (gSHAppBarMessage(ABM_GETTASKBARPOS, &appBarData))
--- a/widget/src/windows/nsNativeThemeWin.cpp
+++ b/widget/src/windows/nsNativeThemeWin.cpp
@@ -274,17 +274,17 @@ static CloseThemeDataPtr closeTheme = NU
static DrawThemeBackgroundPtr drawThemeBG = NULL;
static DrawThemeEdgePtr drawThemeEdge = NULL;
static GetThemeContentRectPtr getThemeContentRect = NULL;
static GetThemePartSizePtr getThemePartSize = NULL;
static GetThemeSysFontPtr getThemeSysFont = NULL;
static GetThemeColorPtr getThemeColor = NULL;
static GetThemeMarginsPtr getThemeMargins = NULL;
-static const char kThemeLibraryName[] = "uxtheme.dll";
+static const PRUnichar kThemeLibraryName[] = L"uxtheme.dll";
static inline bool IsCheckboxWidgetType(PRUint8 aWidgetType)
{
return (aWidgetType == NS_THEME_CHECKBOX || aWidgetType == NS_THEME_CHECKBOX_SMALL);
}
static inline bool IsRadioWidgetType(PRUint8 aWidgetType)
{
@@ -313,17 +313,17 @@ nsNativeThemeWin::nsNativeThemeWin() {
mScaleTheme = NULL;
mStatusbarTheme = NULL;
mTabTheme = NULL;
mTreeViewTheme = NULL;
mComboBoxTheme = NULL;
mHeaderTheme = NULL;
mMenuTheme = NULL;
- mThemeDLL = ::LoadLibrary(kThemeLibraryName);
+ mThemeDLL = ::LoadLibraryW(kThemeLibraryName);
if (mThemeDLL) {
openTheme = (OpenThemeDataPtr)GetProcAddress(mThemeDLL, "OpenThemeData");
closeTheme = (CloseThemeDataPtr)GetProcAddress(mThemeDLL, "CloseThemeData");
drawThemeBG = (DrawThemeBackgroundPtr)GetProcAddress(mThemeDLL, "DrawThemeBackground");
drawThemeEdge = (DrawThemeEdgePtr)GetProcAddress(mThemeDLL, "DrawThemeEdge");
getThemeContentRect = (GetThemeContentRectPtr)GetProcAddress(mThemeDLL, "GetThemeBackgroundContentRect");
getThemePartSize = (GetThemePartSizePtr)GetProcAddress(mThemeDLL, "GetThemePartSize");
getThemeSysFont = (GetThemeSysFontPtr)GetProcAddress(mThemeDLL, "GetThemeSysFont");
--- a/widget/src/windows/nsSound.cpp
+++ b/widget/src/windows/nsSound.cpp
@@ -35,17 +35,17 @@
* 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 ***** */
#include "nscore.h"
#include "plstr.h"
#include <stdio.h>
-
+#include "nsString.h"
#include <windows.h>
// mmsystem.h is needed to build with WIN32_LEAN_AND_MEAN
#include <mmsystem.h>
#include "nsSound.h"
#include "nsIURL.h"
#include "nsNetUtil.h"
@@ -120,17 +120,17 @@ NS_IMETHODIMP nsSound::OnStreamComplete(
// We try to make a copy so we can play it async.
mLastSound = (PRUint8 *) malloc(dataLen);
if (mLastSound) {
memcpy(mLastSound, data, dataLen);
data = mLastSound;
flags |= SND_ASYNC;
}
- ::PlaySound(reinterpret_cast<const char*>(data), 0, flags);
+ ::PlaySoundA(reinterpret_cast<const char*>(data), 0, flags);
}
return NS_OK;
}
NS_IMETHODIMP nsSound::Play(nsIURL *aURL)
{
nsresult rv;
@@ -161,19 +161,17 @@ NS_IMETHODIMP nsSound::Init()
}
NS_IMETHODIMP nsSound::PlaySystemSound(const nsAString &aSoundAlias)
{
PurgeLastSound();
if (aSoundAlias.EqualsLiteral("_moz_mailbeep")) {
- ::PlaySound("MailBeep", nsnull, SND_ALIAS | SND_ASYNC);
+ ::PlaySoundW(L"MailBeep", nsnull, SND_ALIAS | SND_ASYNC);
}
else {
- nsCAutoString nativeSoundAlias;
- NS_CopyUnicodeToNative(aSoundAlias, nativeSoundAlias);
- ::PlaySound(nativeSoundAlias.get(), nsnull, SND_ALIAS | SND_ASYNC);
+ ::PlaySoundW(PromiseFlatString(aSoundAlias).get(), nsnull, SND_ALIAS | SND_ASYNC);
}
return NS_OK;
}
--- a/widget/src/windows/nsToolkit.cpp
+++ b/widget/src/windows/nsToolkit.cpp
@@ -259,17 +259,17 @@ nsToolkit::Startup(HMODULE hModule)
wc.lpszMenuName = NULL;
wc.lpszClassName = L"nsToolkitClass";
VERIFY(::RegisterClassW(&wc));
// Vista API. Mozilla is DPI Aware.
typedef BOOL (*SetProcessDPIAwareFunc)(VOID);
SetProcessDPIAwareFunc setDPIAware = (SetProcessDPIAwareFunc)
- GetProcAddress(LoadLibrary("user32.dll"),
+ GetProcAddress(LoadLibraryW(L"user32.dll"),
"SetProcessDPIAware");
if (setDPIAware)
setDPIAware();
}
void
@@ -290,18 +290,18 @@ void nsToolkit::CreateInternalWindow(PRT
NS_PRECONDITION(aThread, "null thread");
mGuiThread = aThread;
//
// create the internal window
//
- mDispatchWnd = ::CreateWindow("nsToolkitClass",
- "NetscapeDispatchWnd",
+ mDispatchWnd = ::CreateWindowW(L"nsToolkitClass",
+ L"NetscapeDispatchWnd",
WS_DISABLED,
-50, -50,
10, 10,
NULL,
NULL,
nsToolkit::mDllInstance,
NULL);
--- a/widget/src/windows/nsWindow.cpp
+++ b/widget/src/windows/nsWindow.cpp
@@ -145,17 +145,17 @@
#include "nsCRT.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsXPIDLString.h"
#include "nsIFile.h"
#include "prprf.h"
#include "prmem.h"
-static const char kMozHeapDumpMessageString[] = "MOZ_HeapDump";
+static const PRUnichar kMozHeapDumpMessageString[] = L"MOZ_HeapDump";
#define kWindowPositionSlop 20
#ifndef SPI_GETWHEELSCROLLLINES
#define SPI_GETWHEELSCROLLLINES 104
#endif
#ifndef WM_MOUSEHWHEEL
@@ -694,17 +694,17 @@ nsWindow::nsWindow() : nsBaseWidget()
gbInitGlobalValue = TRUE;
gKeyboardLayout = GetKeyboardLayout(0);
// mouse message of MSIME98/2000
nsWindow::uWM_MSIME_MOUSE = ::RegisterWindowMessage(RWM_MOUSE);
// Heap dump
#ifndef WINCE
- nsWindow::uWM_HEAP_DUMP = ::RegisterWindowMessage(kMozHeapDumpMessageString);
+ nsWindow::uWM_HEAP_DUMP = ::RegisterWindowMessageW(kMozHeapDumpMessageString);
#endif
}
mNativeDragTarget = nsnull;
mIsTopWidgetWindow = PR_FALSE;
mLastKeyboardLayout = 0;
#ifndef WINCE
@@ -1114,36 +1114,36 @@ nsWindow::EventIsInsideWindow(UINT Msg,
POINT mp;
mp.x = GET_X_LPARAM(pos);
mp.y = GET_Y_LPARAM(pos);
// was the event inside this window?
return (PRBool) PtInRect(&r, mp);
}
-static char sPropName[40] = "";
-static char* GetNSWindowPropName() {
+static PRUnichar sPropName[40] = L"";
+static PRUnichar* GetNSWindowPropName() {
if (!*sPropName)
{
- _snprintf(sPropName, 39, "MozillansIWidgetPtr%p", _getpid());
+ _snwprintf(sPropName, 39, L"MozillansIWidgetPtr%p", _getpid());
sPropName[39] = '\0';
}
return sPropName;
}
nsWindow * nsWindow::GetNSWindowPtr(HWND aWnd) {
- return (nsWindow *) ::GetPropA(aWnd, GetNSWindowPropName());
+ return (nsWindow *) ::GetPropW(aWnd, GetNSWindowPropName());
}
BOOL nsWindow::SetNSWindowPtr(HWND aWnd, nsWindow * ptr) {
if (ptr == NULL) {
- ::RemovePropA(aWnd, GetNSWindowPropName());
+ ::RemovePropW(aWnd, GetNSWindowPropName());
return TRUE;
} else {
- return ::SetPropA(aWnd, GetNSWindowPropName(), (HANDLE)ptr);
+ return ::SetPropW(aWnd, GetNSWindowPropName(), (HANDLE)ptr);
}
}
//-------------------------------------------------------------------------
//
// the nsWindow procedure for all nsWindows in this toolkit
//
//-------------------------------------------------------------------------
@@ -1783,17 +1783,17 @@ NS_IMETHODIMP nsWindow::SetSizeMode(PRIn
// next window.
::SetWindowPos(mWnd, HWND_BOTTOM, 0, 0, 0, 0,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
if (hwndBelow)
::SetForegroundWindow(hwndBelow);
// Play the minimize sound while we're here, since that is also
// forgotten when we use SW_SHOWMINIMIZED.
- ::PlaySound("Minimize", nsnull, SND_ALIAS | SND_NODEFAULT | SND_ASYNC);
+ ::PlaySoundW(L"Minimize", nsnull, SND_ALIAS | SND_NODEFAULT | SND_ASYNC);
}
#endif
break;
default :
mode = SW_RESTORE;
}
::ShowWindow(mWnd, mode);
}
@@ -5187,52 +5187,58 @@ LPCWSTR nsWindow::WindowPopupClassW()
wc.style = CS_DBLCLKS;
nsWindow::sIsPopupClassRegistered = ::RegisterClassW(&wc);
}
}
return className;
}
-LPCSTR nsWindow::WindowClass()
+LPCTSTR nsWindow::WindowClass()
{
// Call into the wide version to make sure things get
// registered properly.
LPCWSTR classNameW = WindowClassW();
// XXX: The class name used here must be kept in sync with
// the classname used in WindowClassW();
-
+#ifdef UNICODE
+ return classNameW;
+#else
if (classNameW == kWClassNameHidden) {
return kClassNameHidden;
}
if (classNameW == kWClassNameDialog) {
return kClassNameDialog;
}
if (classNameW == kWClassNameUI) {
return kClassNameUI;
}
if (classNameW == kWClassNameContent) {
return kClassNameContent;
}
if (classNameW == kWClassNameContentFrame) {
return kClassNameContentFrame;
}
return kClassNameGeneral;
-}
-
-LPCSTR nsWindow::WindowPopupClass()
+#endif
+}
+
+LPCTSTR nsWindow::WindowPopupClass()
{
// Call into the wide version to make sure things get
// registered properly.
- WindowPopupClassW();
+#ifdef UNICODE
+ return WindowPopupClassW();
+#else
// XXX: The class name used here must be kept in sync with
// the classname used in WindowPopupClassW();
return "MozillaDropShadowWindowClass";
+#endif
}
//-------------------------------------------------------------------------
//
// return nsWindow styles
//
//-------------------------------------------------------------------------
DWORD nsWindow::WindowStyle()
@@ -7713,17 +7719,17 @@ already_AddRefed<nsIAccessible> nsWindow
HINSTANCE nsWindow::gmAccLib = 0;
LPFNLRESULTFROMOBJECT nsWindow::gmLresultFromObject = 0;
STDMETHODIMP_(LRESULT) nsWindow::LresultFromObject(REFIID riid, WPARAM wParam, LPUNKNOWN pAcc)
{
// open the dll dynamically
if (!gmAccLib)
- gmAccLib =::LoadLibrary("OLEACC.DLL");
+ gmAccLib =::LoadLibraryW(L"OLEACC.DLL");
if (gmAccLib) {
if (!gmLresultFromObject)
gmLresultFromObject = (LPFNLRESULTFROMOBJECT)GetProcAddress(gmAccLib,"LresultFromObject");
if (gmLresultFromObject)
return gmLresultFromObject(riid,wParam,pAcc);
}
--- a/widget/src/windows/nsWindow.h
+++ b/widget/src/windows/nsWindow.h
@@ -100,16 +100,23 @@ const LPCWSTR kWClassNameContentFrame =
const LPCWSTR kWClassNameGeneral = L"MozillaWindowClass";
const LPCWSTR kWClassNameDialog = L"MozillaDialogClass";
const LPCSTR kClassNameHidden = "MozillaHiddenWindowClass";
const LPCSTR kClassNameUI = "MozillaUIWindowClass";
const LPCSTR kClassNameContent = "MozillaContentWindowClass";
const LPCSTR kClassNameContentFrame = "MozillaContentFrameWindowClass";
const LPCSTR kClassNameGeneral = "MozillaWindowClass";
const LPCSTR kClassNameDialog = "MozillaDialogClass";
+const LPCTSTR kTClassNameHidden = TEXT("MozillaHiddenWindowClass");
+const LPCTSTR kTClassNameUI = TEXT("MozillaUIWindowClass");
+const LPCTSTR kTClassNameContent = TEXT("MozillaContentWindowClass");
+const LPCTSTR kTClassNameContentFrame = TEXT("MozillaContentFrameWindowClass");
+const LPCTSTR kTClassNameGeneral = TEXT("MozillaWindowClass");
+const LPCTSTR kTClassNameDialog = TEXT("MozillaDialogClass");
+
/**
* Native WIN32 window wrapper.
*/
class nsWindow : public nsSwitchToUIThread,
public nsBaseWidget,
public nsIKBStateControl
--- a/xpcom/base/nsDebugImpl.cpp
+++ b/xpcom/base/nsDebugImpl.cpp
@@ -61,16 +61,21 @@
#include "nsTraceRefcntImpl.h"
#include "nsISupportsUtils.h"
#if defined(XP_UNIX)
#include <signal.h>
#endif
+#if defined(XP_WIN)
+#include <tchar.h>
+#include "nsString.h"
+#endif
+
static void
Abort(const char *aMsg);
static void
Break(const char *aMsg);
#if defined(XP_OS2)
# define INCL_WINDIALOGS // need for WinMessageBox
@@ -92,17 +97,17 @@ Break(const char *aMsg);
#if defined (_WIN32)
typedef WINBASEAPI BOOL (WINAPI* LPFNISDEBUGGERPRESENT)();
PRBool InDebugger()
{
#ifndef WINCE
PRBool fReturn = PR_FALSE;
LPFNISDEBUGGERPRESENT lpfnIsDebuggerPresent = NULL;
- HINSTANCE hKernel = LoadLibrary("Kernel32.dll");
+ HINSTANCE hKernel = LoadLibraryW(L"Kernel32.dll");
if(hKernel)
{
lpfnIsDebuggerPresent =
(LPFNISDEBUGGERPRESENT)GetProcAddress(hKernel, "IsDebuggerPresent");
if(lpfnIsDebuggerPresent)
{
fReturn = (*lpfnIsDebuggerPresent)();
@@ -396,34 +401,36 @@ Break(const char *aMsg)
DWORD code = IDRETRY;
/* Create the debug dialog out of process to avoid the crashes caused by
* Windows events leaking into our event loop from an in process dialog.
* We do this by launching windbgdlg.exe (built in xpcom/windbgdlg).
* See http://bugzilla.mozilla.org/show_bug.cgi?id=54792
*/
PROCESS_INFORMATION pi;
- STARTUPINFO si;
- char executable[MAX_PATH];
- char* pName;
+ STARTUPINFOW si;
+ PRUnichar executable[MAX_PATH];
+ PRUnichar* pName;
memset(&pi, 0, sizeof(pi));
memset(&si, 0, sizeof(si));
si.cb = sizeof(si);
si.wShowWindow = SW_SHOW;
// 2nd arg of CreateProcess is in/out
- char *msgCopy = (char*) _alloca(strlen(aMsg) + 1);
- strcpy(msgCopy, aMsg);
+ PRUnichar *msgCopy = (PRUnichar*) _alloca((strlen(aMsg) + 1)*sizeof(PRUnichar));
+ wcscpy(msgCopy , (PRUnichar*)NS_ConvertUTF8toUTF16(aMsg).get());
- if(GetModuleFileName(GetModuleHandle("xpcom.dll"), executable, MAX_PATH) &&
- NULL != (pName = strrchr(executable, '\\')) &&
- NULL != strcpy(pName+1, "windbgdlg.exe") &&
- CreateProcess(executable, msgCopy, NULL, NULL, PR_FALSE,
+ if(GetModuleFileNameW(GetModuleHandleW(L"xpcom.dll"), (LPWCH)executable, MAX_PATH) &&
+ NULL != (pName = wcsrchr(executable, '\\')) &&
+ NULL !=
+ wcscpy((WCHAR*)
+ pName+1, L"windbgdlg.exe") &&
+ CreateProcessW((LPCWSTR)executable, (LPWSTR)msgCopy, NULL, NULL, PR_FALSE,
DETACHED_PROCESS | NORMAL_PRIORITY_CLASS,
NULL, NULL, &si, &pi)) {
WaitForSingleObject(pi.hProcess, INFINITE);
GetExitCodeProcess(pi.hProcess, &code);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
}
--- a/xpcom/base/nsStackWalk.cpp
+++ b/xpcom/base/nsStackWalk.cpp
@@ -323,19 +323,19 @@ EnsureImageHlpInitialized()
::CloseHandle(hStackWalkThread);
// Wait for the thread's event loop to start before posting events to it.
::WaitForSingleObject(readyEvent, INFINITE);
::CloseHandle(readyEvent);
::InitializeCriticalSection(&gDbgHelpCS);
- HMODULE module = ::LoadLibrary("DBGHELP.DLL");
+ HMODULE module = ::LoadLibraryW(L"DBGHELP.DLL");
if (!module) {
- module = ::LoadLibrary("IMAGEHLP.DLL");
+ module = ::LoadLibraryW(L"IMAGEHLP.DLL");
if (!module) return PR_FALSE;
}
_SymSetOptions = (SYMSETOPTIONSPROC) ::GetProcAddress(module, "SymSetOptions");
if (!_SymSetOptions) return PR_FALSE;
_SymInitialize = (SYMINITIALIZEPROC) ::GetProcAddress(module, "SymInitialize");
if (!_SymInitialize) return PR_FALSE;
--- a/xpcom/io/SpecialSystemDirectory.cpp
+++ b/xpcom/io/SpecialSystemDirectory.cpp
@@ -122,17 +122,17 @@ static nsGetKnownFolderPath gGetKnownFol
static HINSTANCE gShell32DLLInst = NULL;
#endif
NS_COM void StartupSpecialSystemDirectory()
{
#if defined (XP_WIN) && !defined (WINCE)
// SHGetKnownFolderPath is only available on Windows Vista
// so that we need to use GetProcAddress to get the pointer.
- gShell32DLLInst = LoadLibrary("Shell32.dll");
+ gShell32DLLInst = LoadLibraryW(L"Shell32.dll");
if(gShell32DLLInst)
{
gGetKnownFolderPath = (nsGetKnownFolderPath)
GetProcAddress(gShell32DLLInst, "SHGetKnownFolderPath");
}
#endif
}
--- a/xpcom/io/nsLocalFileWin.cpp
+++ b/xpcom/io/nsLocalFileWin.cpp
@@ -103,18 +103,18 @@ public:
NS_DECL_NSISIMPLEENUMERATOR
nsresult Init();
private:
/* mDrives and mLetter share data
* Init sets them.
* HasMoreElements reads mLetter.
* GetNext advances mLetter.
*/
- nsCString mDrives;
- const char *mLetter;
+ nsString mDrives;
+ const PRUnichar *mLetter;
};
//----------------------------------------------------------------------------
// short cut resolver
//----------------------------------------------------------------------------
#ifndef WINCE
class ShortcutResolver
{
@@ -2947,17 +2947,17 @@ nsresult nsDriveEnumerator::Init()
#else
/* If the length passed to GetLogicalDriveStrings is smaller
* than the length of the string it would return, it returns
* the length required for the string. */
DWORD length = GetLogicalDriveStrings(0, 0);
/* The string is null terminated */
if (!EnsureStringLength(mDrives, length+1))
return NS_ERROR_OUT_OF_MEMORY;
- if (!GetLogicalDriveStrings(length, mDrives.BeginWriting()))
+ if (!GetLogicalDriveStringsW(length, mDrives.BeginWriting()))
return NS_ERROR_FAILURE;
mLetter = mDrives.get();
return NS_OK;
#endif
}
NS_IMETHODIMP nsDriveEnumerator::HasMoreElements(PRBool *aHasMore)
{
@@ -2977,18 +2977,19 @@ NS_IMETHODIMP nsDriveEnumerator::GetNext
*aNext = file;
#else
/* GetLogicalDrives stored in mLetter is a concatenation
* of null terminated strings, followed by a null terminator. */
if (!*mLetter) {
*aNext = nsnull;
return NS_OK;
}
- NS_ConvertASCIItoUTF16 drive(mLetter);
+ nsString drive(mDrives);
mLetter += drive.Length() + 1;
+
nsILocalFile *file;
nsresult rv =
NS_NewLocalFile(drive, PR_FALSE, &file);
*aNext = file;
#endif
return rv;
}
--- a/xpcom/threads/nsProcessCommon.cpp
+++ b/xpcom/threads/nsProcessCommon.cpp
@@ -101,20 +101,21 @@ nsProcess::Init(nsIFile* executable)
#endif
rv = mExecutable->GetNativePath(mTargetPath);
return rv;
}
#if defined(XP_WIN)
-static int assembleCmdLine(char *const *argv, char **cmdLine)
+static int assembleCmdLine(char *const *argv, PRUnichar **cmdLine)
{
char *const *arg;
- char *p, *q;
+ PRUnichar *p;
+ char *q;
int cmdLineSize;
int numBackslashes;
int i;
int argNeedQuotes;
/*
* Find out how large the command line buffer should be.
*/
@@ -126,17 +127,17 @@ static int assembleCmdLine(char *const *
* may double. If we quote an argument, that needs two ".
* Finally, we need a space between arguments, and
* a null byte at the end of command line.
*/
cmdLineSize += 2 * strlen(*arg) /* \ and " need to be escaped */
+ 2 /* we quote every argument */
+ 1; /* space in between, or final null */
}
- p = *cmdLine = (char *) PR_MALLOC(cmdLineSize);
+ p = *cmdLine = (PRUnichar *) PR_MALLOC(cmdLineSize*sizeof(PRUnichar));
if (p == NULL) {
return -1;
}
for (arg = argv; *arg; arg++) {
/* Add a space to separates the arguments */
if (arg != argv) {
*p++ = ' ';
@@ -232,43 +233,43 @@ nsProcess::Run(PRBool blocking, const ch
my_argv[i+1] = const_cast<char*>(args[i]);
}
// we need to set argv[0] to the program name.
my_argv[0] = mTargetPath.BeginWriting();
// null terminate the array
my_argv[count+1] = NULL;
#if defined(XP_WIN) && !defined (WINCE) /* wince uses nspr */
- STARTUPINFO startupInfo;
+ STARTUPINFOW startupInfo;
PROCESS_INFORMATION procInfo;
BOOL retVal;
- char *cmdLine;
+ PRUnichar *cmdLine;
if (assembleCmdLine(my_argv, &cmdLine) == -1) {
nsMemory::Free(my_argv);
return NS_ERROR_FILE_EXECUTION_FAILED;
}
ZeroMemory(&startupInfo, sizeof(startupInfo));
startupInfo.cb = sizeof(startupInfo);
- retVal = CreateProcess(NULL,
- // const_cast<char*>(mTargetPath.get()),
- cmdLine,
- NULL, /* security attributes for the new
- * process */
- NULL, /* security attributes for the primary
- * thread in the new process */
- FALSE, /* inherit handles */
- 0, /* creation flags */
- NULL, /* env */
- NULL, /* current drive and directory */
- &startupInfo,
- &procInfo
- );
+ retVal = CreateProcessW(NULL,
+ // const_cast<char*>(mTargetPath.get()),
+ cmdLine,
+ NULL, /* security attributes for the new
+ * process */
+ NULL, /* security attributes for the primary
+ * thread in the new process */
+ FALSE, /* inherit handles */
+ 0, /* creation flags */
+ NULL, /* env */
+ NULL, /* current drive and directory */
+ &startupInfo,
+ &procInfo
+ );
PR_Free( cmdLine );
if (blocking) {
// if success, wait for process termination. the early returns and such
// are a bit ugly but preserving the logic of the nspr code I copied to
// minimize our risk abit.
if ( retVal == TRUE ) {
--- a/xpcom/windbgdlg/Makefile.in
+++ b/xpcom/windbgdlg/Makefile.in
@@ -37,14 +37,16 @@
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
+OS_LIBS += shell32.lib
+
SIMPLE_PROGRAMS = windbgdlg$(BIN_SUFFIX)
CPPSRCS = windbgdlg.cpp
include $(topsrcdir)/config/rules.mk
--- a/xpcom/windbgdlg/windbgdlg.cpp
+++ b/xpcom/windbgdlg/windbgdlg.cpp
@@ -37,16 +37,17 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* Windows only app to show a modal debug dialog - launched by nsDebug.cpp */
#include <windows.h>
#include <stdlib.h>
+#include <shellapi.h>
int WINAPI
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdLine, int nCmdShow)
{
/* support for auto answering based on words in the assertion.
* the assertion message is sent as a series of arguements (words) to the commandline.
* set a "word" to 0xffffffff to let the word not affect this code.
@@ -54,38 +55,39 @@ WinMain(HINSTANCE hInstance, HINSTANCE
* set a "word" to 0x5 to ignore (program should continue).
* set a "word" to 0x4 to retry (should fall into debugger).
* set a "word" to 0x3 to abort (die).
*/
DWORD regType;
DWORD regValue = -1;
DWORD regLength = sizeof regValue;
HKEY hkeyCU, hkeyLM;
- RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\mozilla.org\\windbgdlg", 0, KEY_READ, &hkeyCU);
- RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\mozilla.org\\windbgdlg", 0, KEY_READ, &hkeyLM);
- const char * const * argv = __argv;
- for (int i = __argc - 1; regValue == (DWORD)-1 && i; --i) {
+ RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\mozilla.org\\windbgdlg", 0, KEY_READ, &hkeyCU);
+ RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\mozilla.org\\windbgdlg", 0, KEY_READ, &hkeyLM);
+ int argc =0;
+ LPWSTR *argv = CommandLineToArgvW(GetCommandLineW(), &argc);
+ for (int i = argc - 1; regValue == (DWORD)-1 && i; --i) {
bool ok = false;
if (hkeyCU)
ok = RegQueryValueEx(hkeyCU, argv[i], 0, ®Type, (LPBYTE)®Value, ®Length) == ERROR_SUCCESS;
if (!ok && hkeyLM)
ok = RegQueryValueEx(hkeyLM, argv[i], 0, ®Type, (LPBYTE)®Value, ®Length) == ERROR_SUCCESS;
if (!ok)
regValue = -1;
}
if (hkeyCU)
RegCloseKey(hkeyCU);
if (hkeyLM)
RegCloseKey(hkeyLM);
if (regValue != (DWORD)-1 && regValue != (DWORD)-2)
return regValue;
- static char msg[4048];
+ static PRUnichar msg[4048];
wsprintf(msg,
- "%s\n\nClick Abort to exit the Application.\n"
- "Click Retry to Debug the Application..\n"
- "Click Ignore to continue running the Application.",
+ L"%s\n\nClick Abort to exit the Application.\n"
+ L"Click Retry to Debug the Application..\n"
+ L"Click Ignore to continue running the Application.",
lpszCmdLine);
- return MessageBox(NULL, msg, "NSGlue_Assertion",
+ return MessageBoxW(NULL, msg, L"NSGlue_Assertion",
MB_ICONSTOP | MB_SYSTEMMODAL|
MB_ABORTRETRYIGNORE | MB_DEFBUTTON3);
}
--- a/xpfe/bootstrap/showOSAlert.cpp
+++ b/xpfe/bootstrap/showOSAlert.cpp
@@ -34,16 +34,17 @@
* 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 ***** */
#include <stdio.h>
#include <string.h>
#include "nscore.h"
+#include "nsString.h"
//defines and includes for previous installation cleanup process
#if defined (XP_WIN)
#include <windows.h>
#elif defined (XP_MAC)
#include <Dialogs.h>
#include <TextUtils.h>
#elif defined (XP_OS2)
@@ -58,25 +59,28 @@ extern "C" void ShowOSAlert(const char*
// The maximum allowed length of aMessage is 255 characters!
void ShowOSAlert(const char* aMessage)
{
#ifdef DEBUG_dbragg
printf("\n****Inside ShowOSAlert ***\n");
#endif
const PRInt32 max_len = 255;
- char message_copy[max_len+1] = { 0 };
PRInt32 input_len = strlen(aMessage);
PRInt32 copy_len = (input_len > max_len) ? max_len : input_len;
+#if defined (XP_WIN)
+ NS_ConvertUTF8toUTF16 msg_str(aMessage, copy_len);
+ PRUnichar* message_copy = (PRUnichar*)msg_str.get();
+ MessageBoxW(NULL, message_copy, NULL, MB_OK | MB_ICONERROR | MB_SETFOREGROUND );
+#else
+ char message_copy[max_len+1] = { 0 };
strncpy(message_copy, aMessage, copy_len);
message_copy[copy_len] = 0;
-
-#if defined (XP_WIN)
- MessageBoxA(NULL, message_copy, NULL, MB_OK | MB_ICONERROR | MB_SETFOREGROUND );
-#elif (XP_MAC)
+#endif
+#if (XP_MAC)
short buttonClicked;
StandardAlert(kAlertStopAlert, c2pstr(message_copy), nil, nil, &buttonClicked);
#elif defined (XP_OS2)
/* Set our app to be a PM app before attempting Win calls */
PPIB ppib;
PTIB ptib;
DosGetInfoBlocks(&ptib, &ppib);
ppib->pib_ultype = 3;