bug 359808 : drop support for Win9x/ME (get rid of 'A' API code) : r=darin, sr=dougt, sr=darin

This commit is contained in:
jshin%mailaps.org 2007-02-08 17:48:22 +00:00
parent 6a1240f708
commit 88da57650a
10 changed files with 81 additions and 298 deletions

View File

@ -114,31 +114,6 @@ HRESULT CRegTaskPATH::DoTask()
CString szBinDirPath;
m_pTaskMgr->GetValue(c_szValueBinDirPath, szBinDirPath);
OSVERSIONINFO osvi;
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO)
GetVersionEx(&osvi);
if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)
{
}
else if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
{
FILE *f = fopen("c:\\autoexec.bat", "rw");
if (f == NULL)
{
return NULL;
}
// TODO read autoexec.bat if necessary and add Mozilla bin path to it
// READ whole thing into memory
// grep for magic control tags
// if there then replace section
// else append new section
fclose(f);
}
return S_OK;
}

View File

@ -80,16 +80,6 @@ nsresult nsCollationWin::Initialize(nsILocale* locale)
return NS_ERROR_OUT_OF_MEMORY;
}
OSVERSIONINFO os;
os.dwOSVersionInfoSize = sizeof(os);
::GetVersionEx(&os);
if (VER_PLATFORM_WIN32_NT == os.dwPlatformId && os.dwMajorVersion >= 4) {
mW_API = PR_TRUE;
}
else {
mW_API = PR_FALSE;
}
// default LCID (en-US)
mLCID = 1033;
@ -151,38 +141,19 @@ NS_IMETHODIMP nsCollationWin::CompareString(PRInt32 strength,
if (strength == kCollationCaseInSensitive)
dwMapFlags |= NORM_IGNORECASE;
if (mW_API) {
#endif
retval = ::CompareStringW(mLCID,
dwMapFlags,
(LPCWSTR) PromiseFlatString(string1).get(),
-1,
(LPCWSTR) PromiseFlatString(string2).get(),
-1);
if (retval) {
res = NS_OK;
*result = retval - 2;
} else {
res = NS_ERROR_FAILURE;
}
#ifndef WINCE // Always use wide APIs on Win CE.
retval = ::CompareStringW(mLCID,
dwMapFlags,
(LPCWSTR) PromiseFlatString(string1).get(),
-1,
(LPCWSTR) PromiseFlatString(string2).get(),
-1);
if (retval) {
res = NS_OK;
*result = retval - 2;
} else {
char *Cstr1 = nsnull, *Cstr2 = nsnull;
res = mCollation->UnicodeToChar(string1, &Cstr1);
if (NS_SUCCEEDED(res) && Cstr1 != nsnull) {
res = mCollation->UnicodeToChar(string2, &Cstr2);
if (NS_SUCCEEDED(res) && Cstr2 != nsnull) {
retval = CompareStringA(mLCID, dwMapFlags, Cstr1, -1, Cstr2, -1);
if (retval)
*result = retval - 2;
else
res = NS_ERROR_FAILURE;
PR_Free(Cstr2);
}
PR_Free(Cstr1);
}
res = NS_ERROR_FAILURE;
}
#endif //WINCE
return res;
}
@ -199,39 +170,18 @@ nsresult nsCollationWin::AllocateRawSortKey(PRInt32 strength,
if (strength == kCollationCaseInSensitive)
dwMapFlags |= NORM_IGNORECASE;
#ifndef WINCE // Always use wide APIs on Win CE.
if (mW_API) {
#endif
byteLen = LCMapStringW(mLCID, dwMapFlags,
byteLen = LCMapStringW(mLCID, dwMapFlags,
(LPCWSTR) PromiseFlatString(stringIn).get(),
-1, NULL, 0);
buffer = PR_Malloc(byteLen);
if (!buffer) {
res = NS_ERROR_OUT_OF_MEMORY;
} else {
*key = (PRUint8 *)buffer;
*outLen = LCMapStringW(mLCID, dwMapFlags,
(LPCWSTR) PromiseFlatString(stringIn).get(),
-1, NULL, 0);
buffer = PR_Malloc(byteLen);
if (!buffer) {
res = NS_ERROR_OUT_OF_MEMORY;
} else {
*key = (PRUint8 *)buffer;
*outLen = LCMapStringW(mLCID, dwMapFlags,
(LPCWSTR) PromiseFlatString(stringIn).get(),
-1, (LPWSTR) buffer, byteLen);
}
#ifndef WINCE // Always use wide APIs on Win CE.
-1, (LPWSTR) buffer, byteLen);
}
else {
char *Cstr = nsnull;
res = mCollation->UnicodeToChar(stringIn, &Cstr);
if (NS_SUCCEEDED(res) && Cstr != nsnull) {
byteLen = LCMapStringA(mLCID, dwMapFlags, Cstr, -1, NULL, 0);
buffer = PR_Malloc(byteLen);
if (!buffer) {
res = NS_ERROR_OUT_OF_MEMORY;
} else {
*key = (PRUint8 *)buffer;
*outLen = LCMapStringA(mLCID, dwMapFlags, Cstr, -1, (char *) buffer, byteLen);
}
PR_Free(Cstr);
}
}
#endif
return res;
}

View File

@ -50,7 +50,6 @@ class nsCollationWin : public nsICollation {
protected:
nsCollation *mCollation; // XP collation class
PRBool mW_API; // If Windows95 or 98, we cannot use W version of API
PRUint32 mLCID; // Windows platform locale ID
public:

View File

@ -76,17 +76,6 @@ nsresult nsDateTimeFormatWin::Initialize(nsILocale* locale)
}
}
// get os version
OSVERSIONINFO os;
os.dwOSVersionInfoSize = sizeof(os);
::GetVersionEx(&os);
if (VER_PLATFORM_WIN32_NT == os.dwPlatformId && os.dwMajorVersion >= 4) {
mW_API = PR_TRUE; // has W API
}
else {
mW_API = PR_FALSE;
}
// default LCID (en-US)
mLCID = 1033;
@ -285,25 +274,10 @@ int nsDateTimeFormatWin::nsGetTimeFormatW(DWORD dwFlags, const SYSTEMTIME *lpTim
{
int len = 0;
#ifndef WINCE // Always use wide APIs on Win CE.
if (mW_API) {
#endif
nsString formatString; if (format) formatString.AssignWithConversion(format);
LPCWSTR wstr = format ? (LPCWSTR) formatString.get() : NULL;
len = GetTimeFormatW(mLCID, dwFlags, lpTime, wstr, (LPWSTR) timeStr, cchTime);
#ifndef WINCE // Always use wide APIs on Win CE.
}
else {
char cstr_time[NSDATETIMEFORMAT_BUFFER_LEN];
len = GetTimeFormatA(mLCID, dwFlags, lpTime, (LPCSTR) format,
(LPSTR) cstr_time, NSDATETIMEFORMAT_BUFFER_LEN);
// convert result to unicode
if (len > 0)
len = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, (LPCSTR) cstr_time, len, (LPWSTR) timeStr, cchTime);
}
#endif
LPCWSTR wstr = NULL;
if (format)
wstr = NS_CONST_CAST(LPCWSTR, NS_ConvertASCIItoUTF16(format).get());
len = GetTimeFormatW(mLCID, dwFlags, lpTime, wstr, (LPWSTR) timeStr, cchTime);
return len;
}
@ -312,24 +286,9 @@ int nsDateTimeFormatWin::nsGetDateFormatW(DWORD dwFlags, const SYSTEMTIME *lpDat
{
int len = 0;
#ifndef WINCE // Always use wide APIs on Win CE.
if (mW_API) {
#endif
nsString formatString; if (format) formatString.AssignWithConversion(format);
LPCWSTR wstr = format ? (LPCWSTR) formatString.get() : NULL;
len = GetDateFormatW(mLCID, dwFlags, lpDate, wstr, (LPWSTR) dateStr, cchDate);
#ifndef WINCE // Always use wide APIs on Win CE.
}
else {
char cstr_date[NSDATETIMEFORMAT_BUFFER_LEN];
len = GetDateFormatA(mLCID, dwFlags, lpDate, (LPCSTR) format,
(LPSTR) cstr_date, NSDATETIMEFORMAT_BUFFER_LEN);
// convert result to unicode
if (len > 0)
len = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, (LPCSTR) cstr_date, len, (LPWSTR) dateStr, cchDate);
}
#endif
LPCWSTR wstr = NULL;
if (format)
wstr = NS_CONST_CAST(LPCWSTR, NS_ConvertASCIItoUTF16(format).get());
len = GetDateFormatW(mLCID, dwFlags, lpDate, wstr, (LPWSTR) dateStr, cchDate);
return len;
}

View File

@ -98,7 +98,6 @@ private:
nsString mLocale;
nsString mAppLocale;
PRBool mW_API; // W or A API
PRUint32 mLCID; // Windows platform locale ID
};

View File

@ -206,52 +206,39 @@ double Stopwatch::GetCPUTime(){
return 0;
#elif defined(WIN32)
OSVERSIONINFO OsVersionInfo;
DWORD ret;
FILETIME ftCreate, // when the process was created
ftExit; // when the process exited
//*-* Value Platform
//*-* ----------------------------------------------------
//*-* VER_PLATFORM_WIN32_WINDOWS Win32 on Windows 95
//*-* VER_PLATFORM_WIN32_NT Windows NT
//*-*
OsVersionInfo.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
GetVersionEx(&OsVersionInfo);
if (OsVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) {
DWORD ret;
FILETIME ftCreate, // when the process was created
ftExit; // when the process exited
union {FILETIME ftFileTime;
__int64 ftInt64;
} ftKernel; // time the process has spent in kernel mode
union {FILETIME ftFileTime;
__int64 ftInt64;
} ftKernel; // time the process has spent in kernel mode
union {FILETIME ftFileTime;
__int64 ftInt64;
} ftUser; // time the process has spent in user mode
union {FILETIME ftFileTime;
__int64 ftInt64;
} ftUser; // time the process has spent in user mode
HANDLE hProcess = GetCurrentProcess();
ret = GetProcessTimes (hProcess, &ftCreate, &ftExit,
&ftKernel.ftFileTime,
&ftUser.ftFileTime);
if (ret != PR_TRUE){
ret = GetLastError ();
HANDLE hProcess = GetCurrentProcess();
ret = GetProcessTimes (hProcess, &ftCreate, &ftExit,
&ftKernel.ftFileTime,
&ftUser.ftFileTime);
if (ret != PR_TRUE){
ret = GetLastError ();
#ifdef DEBUG
printf("%s 0x%lx\n"," Error on GetProcessTimes", (int)ret);
printf("%s 0x%lx\n"," Error on GetProcessTimes", (int)ret);
#endif
}
/*
* Process times are returned in a 64-bit structure, as the number of
* 100 nanosecond ticks since 1 January 1601. User mode and kernel mode
* times for this process are in separate 64-bit structures.
* To convert to floating point seconds, we will:
*
* Convert sum of high 32-bit quantities to 64-bit int
*/
/*
* Process times are returned in a 64-bit structure, as the number of
* 100 nanosecond ticks since 1 January 1601. User mode and kernel mode
* times for this process are in separate 64-bit structures.
* To convert to floating point seconds, we will:
*
* Convert sum of high 32-bit quantities to 64-bit int
*/
return (double) (ftKernel.ftInt64 + ftUser.ftInt64) * gTicks;
}
else
return GetRealTime();
return (double) (ftKernel.ftInt64 + ftUser.ftInt64) * gTicks;
#endif
}

View File

@ -103,18 +103,9 @@ nsRASAutodial::nsRASAutodial()
mOSVerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&mOSVerInfo);
#ifndef WINCE
// We only need to dial on nt based systems. For all other platforms,
// mAutodialBehavior will remain AUTODIAL_NEVER, and we can skip
// these initializations.
if ((mOSVerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
&& (mOSVerInfo.dwMajorVersion >= 4))
#endif
{
// Initializations that can be made again since RAS OS settings can
// change.
Init();
}
// Initializations that can be made again since RAS OS settings can
// change.
Init();
}
// dtor

View File

@ -666,14 +666,6 @@ nsHttpHandler::InitUserAgentComponents()
PR_smprintf_free(buf);
}
}
} else if (info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS &&
info.dwMajorVersion == 4) {
if (info.dwMinorVersion == 90)
mOscpu.AssignLiteral("Win 9x 4.90"); // Windows Me
else if (info.dwMinorVersion > 0)
mOscpu.AssignLiteral("Win98");
else
mOscpu.AssignLiteral("Win95");
} else {
char *buf = PR_smprintf("Windows %ld.%ld",
info.dwMajorVersion,

View File

@ -40,7 +40,6 @@
#include <shlwapi.h>
#include <stdlib.h>
#include "nsWindowsRegKey.h"
#include "nsNativeCharsetUtils.h"
#include "nsString.h"
#include "nsCOMPtr.h"
@ -52,18 +51,6 @@
//-----------------------------------------------------------------------------
// This class simplifies conversion from unicode to native charset somewhat.
class PromiseNativeString : public nsCAutoString
{
public:
PromiseNativeString(const nsAString &input)
{
NS_CopyUnicodeToNative(input, *this);
}
};
//-----------------------------------------------------------------------------
// According to MSDN, the following limits apply (in characters excluding room
// for terminating null character):
#define MAX_KEY_NAME_LEN 255

View File

@ -57,24 +57,6 @@
#define MOZ_HWND_BROADCAST_MSG_TIMEOUT 5000
#define MOZ_CLIENT_BROWSER_KEY "Software\\Clients\\StartMenuInternet"
static PRBool IsNT()
{
static PRBool sInitialized = PR_FALSE;
static PRBool sIsNT = PR_FALSE;
if (!sInitialized) {
OSVERSIONINFO osversion;
::ZeroMemory(&osversion, sizeof(OSVERSIONINFO));
osversion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if (::GetVersionEx(&osversion) &&
osversion.dwPlatformId == VER_PLATFORM_WIN32_NT)
sIsNT = PR_TRUE;
sInitialized = PR_TRUE;
}
return sIsNT;
}
// Generate the "full" name of this registry entry.
nsCString RegistryEntry::fullName() const {
nsCString result;
@ -130,46 +112,23 @@ else printf( "Setting %s=%s\n", fullName().get(), setting.get() );
}
} else {
NS_ConvertUTF8toUTF16 utf16Setting(setting);
if (!IsNT()) {
// Get current value to see if it is set properly already.
char buffer[4096] = { 0 };
DWORD len = sizeof buffer;
rc = ::RegQueryValueExA( key, valueNameArg(), NULL, NULL,
(LPBYTE)buffer, &len );
nsCAutoString cSetting;
NS_CopyUnicodeToNative(utf16Setting, cSetting);
if ( rc != ERROR_SUCCESS || !cSetting.Equals(buffer)) {
rc = ::RegSetValueExA( key, valueNameArg(), 0, REG_SZ,
(LPBYTE)cSetting.get(), cSetting.Length() );
#ifdef DEBUG_law
NS_ASSERTION( rc == ERROR_SUCCESS, fullName().get() );
#endif
if ( rc == ERROR_SUCCESS ) {
result = NS_OK;
}
} else {
// Already has desired setting.
// Get current value to see if it is set properly already.
PRUnichar buffer[4096] = { 0 };
DWORD len = sizeof buffer;
NS_ConvertASCIItoUTF16 wValueName(valueNameArg());
rc = ::RegQueryValueExW( key, wValueName.get(), NULL,
NULL, (LPBYTE)buffer, &len );
if ( rc != ERROR_SUCCESS || !utf16Setting.Equals(buffer) ) {
rc = ::RegSetValueExW( key, wValueName.get(), 0, REG_SZ,
(LPBYTE) (utf16Setting.get()),
utf16Setting.Length() * 2);
if ( rc == ERROR_SUCCESS ) {
result = NS_OK;
}
} else {
// Get current value to see if it is set properly already.
PRUnichar buffer[4096] = { 0 };
DWORD len = sizeof buffer;
NS_ConvertASCIItoUTF16 wValueName(valueNameArg());
rc = ::RegQueryValueExW( key, wValueName.get(), NULL,
NULL, (LPBYTE)buffer, &len );
if ( rc != ERROR_SUCCESS || !utf16Setting.Equals(buffer) ) {
rc = ::RegSetValueExW( key, wValueName.get(), 0, REG_SZ,
(LPBYTE) (utf16Setting.get()),
utf16Setting.Length() * 2);
if ( rc == ERROR_SUCCESS ) {
result = NS_OK;
}
} else {
// Already has desired setting.
result = NS_OK;
}
} // NT
}
} else {
// Already has desired setting.
result = NS_OK;
}
}
::RegCloseKey( key );
} else {
@ -509,30 +468,15 @@ nsCString RegistryEntry::currentSetting( PRBool *currentlyUndefined ) const {
HKEY key;
LONG rc = ::RegOpenKey( baseKey, keyName.get(), &key );
if ( rc == ERROR_SUCCESS ) {
if (!IsNT()) {
char buffer[4096] = { 0 };
DWORD len = sizeof buffer;
rc = ::RegQueryValueExA( key, valueNameArg(), NULL, NULL,
(LPBYTE)buffer, &len );
if ( rc == ERROR_SUCCESS ) {
nsAutoString uResult;
NS_CopyNativeToUnicode(nsDependentCString(buffer), uResult);
CopyUTF16toUTF8(uResult, result);
if ( currentlyUndefined ) {
*currentlyUndefined = PR_FALSE; // Indicate entry is present
}
}
} else {
PRUnichar buffer[4096] = { 0 };
DWORD len = sizeof buffer;
rc = ::RegQueryValueExW( key,
NS_ConvertASCIItoUTF16(valueNameArg()).get(), NULL, NULL,
(LPBYTE)buffer, &len );
if ( rc == ERROR_SUCCESS ) {
CopyUTF16toUTF8(buffer, result);
if ( currentlyUndefined ) {
*currentlyUndefined = PR_FALSE; // Indicate entry is present
}
PRUnichar buffer[4096] = { 0 };
DWORD len = sizeof buffer;
rc = ::RegQueryValueExW( key,
NS_ConvertASCIItoUTF16(valueNameArg()).get(), NULL, NULL,
(LPBYTE)buffer, &len );
if ( rc == ERROR_SUCCESS ) {
CopyUTF16toUTF8(buffer, result);
if ( currentlyUndefined ) {
*currentlyUndefined = PR_FALSE; // Indicate entry is present
}
}
::RegCloseKey( key );