diff --git a/netwerk/base/src/nsAutodialWin.cpp b/netwerk/base/src/nsAutodialWin.cpp index 1fe604323ca5..945ac51a5e1b 100644 --- a/netwerk/base/src/nsAutodialWin.cpp +++ b/netwerk/base/src/nsAutodialWin.cpp @@ -43,7 +43,6 @@ #include #include -#include "nsString.h" #include "nsAutodialWin.h" #include "prlog.h" @@ -101,7 +100,7 @@ nsRASAutodial::nsRASAutodial() mNumRASConnectionEntries(0), mAutodialServiceDialingLocation(-1) { - mOSVerInfo.dwOSVersionInfoSize = sizeof(mOSVerInfo); + mOSVerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&mOSVerInfo); // Initializations that can be made again since RAS OS settings can @@ -140,8 +139,8 @@ nsresult nsRASAutodial::Init() mNumRASConnectionEntries = NumRASEntries(); // Get the name of the default entry. - nsresult result = GetDefaultEntryName(mDefaultEntryName, - sizeof(mDefaultEntryName)); + nsresult result = GetDefaultEntryName(mDefaultEntryName, + RAS_MaxEntryName + 1); return result; } @@ -206,9 +205,9 @@ int nsRASAutodial::QueryAutodialBehavior() // If we get to here, then the service is not going to dial on error, so we // can dial ourselves if the control panel settings are set up that way. HKEY hKey = 0; - LONG result = ::RegOpenKeyExW( + LONG result = ::RegOpenKeyEx( HKEY_CURRENT_USER, - L"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", + "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", 0, KEY_READ, &hKey); @@ -224,7 +223,7 @@ int nsRASAutodial::QueryAutodialBehavior() DWORD onDemand = 0; DWORD paramSize = sizeof(DWORD); - result = ::RegQueryValueExW(hKey, L"EnableAutodial", nsnull, &entryType, (LPBYTE)&autodial, ¶mSize); + result = ::RegQueryValueEx(hKey, "EnableAutodial", nsnull, &entryType, (LPBYTE)&autodial, ¶mSize); if (result != ERROR_SUCCESS) { ::RegCloseKey(hKey); @@ -232,7 +231,7 @@ int nsRASAutodial::QueryAutodialBehavior() return AUTODIAL_NEVER; } - result = ::RegQueryValueExW(hKey, L"NoNetAutodial", nsnull, &entryType, (LPBYTE)&onDemand, ¶mSize); + result = ::RegQueryValueEx(hKey, "NoNetAutodial", nsnull, &entryType, (LPBYTE)&onDemand, ¶mSize); if (result != ERROR_SUCCESS) { ::RegCloseKey(hKey); @@ -270,9 +269,9 @@ static nsresult DoPPCConnection() // Make the connection to the new network CONNMGR_CONNECTIONINFO conn_info; - memset(&conn_info, 0, sizeof(conn_info)); + memset(&conn_info, 0, sizeof(CONNMGR_CONNECTIONINFO)); - conn_info.cbSize = sizeof(conn_info); + conn_info.cbSize = sizeof(CONNMGR_CONNECTIONINFO); conn_info.dwParams = CONNMGR_PARAM_GUIDDESTNET; conn_info.dwPriority = CONNMGR_PRIORITY_USERINTERACTIVE; conn_info.guidDestNet = IID_DestNetInternet; @@ -322,7 +321,7 @@ static nsresult DoPPCConnection() // Return values: // NS_OK: dialing was successful and caller should retry // all other values indicate that the caller should not retry -nsresult nsRASAutodial::DialDefault(const PRUnichar* hostName) +nsresult nsRASAutodial::DialDefault(const char* hostName) { #ifndef WINCE mDontRetryUntil = 0; @@ -374,8 +373,8 @@ nsresult nsRASAutodial::DialDefault(const PRUnichar* hostName) LOGD(("Autodial: Dialing default: %s.",mDefaultEntryName)); RASDIALDLG rasDialDlg; - memset(&rasDialDlg, 0, sizeof(rasDialDlg)); - rasDialDlg.dwSize = sizeof(rasDialDlg); + memset(&rasDialDlg, 0, sizeof(RASDIALDLG)); + rasDialDlg.dwSize = sizeof(RASDIALDLG); PRBool dialed = (*mpRasDialDlg)(nsnull, mDefaultEntryName, nsnull, &rasDialDlg); @@ -405,8 +404,8 @@ nsresult nsRASAutodial::DialDefault(const PRUnichar* hostName) LOGD(("Autodial: Prompting for phonebook entry.")); RASPBDLG rasPBDlg; - memset(&rasPBDlg, 0, sizeof(rasPBDlg)); - rasPBDlg.dwSize = sizeof(rasPBDlg); + memset(&rasPBDlg, 0, sizeof(RASPBDLG)); + rasPBDlg.dwSize = sizeof(RASPBDLG); PRBool dialed = (*mpRasPhonebookDlg)(nsnull, nsnull, &rasPBDlg); @@ -444,8 +443,8 @@ PRBool nsRASAutodial::IsRASConnected() { DWORD connections; RASCONN rasConn; - rasConn.dwSize = sizeof(rasConn); - DWORD structSize = sizeof(rasConn); + rasConn.dwSize = sizeof(RASCONN); + DWORD structSize = sizeof(RASCONN); if (!LoadRASapi32DLL()) return NS_ERROR_NULL_POINTER; @@ -463,15 +462,15 @@ PRBool nsRASAutodial::IsRASConnected() } // Get the first RAS dial entry name from the phonebook. -nsresult nsRASAutodial::GetFirstEntryName(PRUnichar* entryName, int bufferSize) +nsresult nsRASAutodial::GetFirstEntryName(char* entryName, int bufferSize) { // Need to load the DLL if not loaded yet. if (!LoadRASapi32DLL()) return NS_ERROR_NULL_POINTER; - RASENTRYNAMEW rasEntryName; - rasEntryName.dwSize = sizeof(rasEntryName); - DWORD cb = sizeof(rasEntryName); + RASENTRYNAME rasEntryName; + rasEntryName.dwSize = sizeof(RASENTRYNAME); + DWORD cb = sizeof(RASENTRYNAME); DWORD cEntries = 0; DWORD result = @@ -480,8 +479,9 @@ nsresult nsRASAutodial::GetFirstEntryName(PRUnichar* entryName, int bufferSize) // ERROR_BUFFER_TOO_SMALL is OK because we only need one struct. if (result == ERROR_SUCCESS || result == ERROR_BUFFER_TOO_SMALL) { - wcsncpy(entryName, rasEntryName.szEntryName, - bufferSize / sizeof(*entryName)); +#ifndef WINCE + strncpy(entryName, rasEntryName.szEntryName, bufferSize); +#endif return NS_OK; } @@ -495,9 +495,9 @@ int nsRASAutodial::NumRASEntries() if (!LoadRASapi32DLL()) return 0; - RASENTRYNAMEW rasEntryName; - rasEntryName.dwSize = sizeof(rasEntryName); - DWORD cb = sizeof(rasEntryName); + RASENTRYNAME rasEntryName; + rasEntryName.dwSize = sizeof(RASENTRYNAME); + DWORD cb = sizeof(RASENTRYNAME); DWORD cEntries = 0; @@ -514,7 +514,7 @@ int nsRASAutodial::NumRASEntries() } // Get the name of the default dial entry. -nsresult nsRASAutodial::GetDefaultEntryName(PRUnichar* entryName, int bufferSize) +nsresult nsRASAutodial::GetDefaultEntryName(char* entryName, int bufferSize) { // No RAS dialup entries. if (mNumRASConnectionEntries <= 0) @@ -535,8 +535,8 @@ nsresult nsRASAutodial::GetDefaultEntryName(PRUnichar* entryName, int bufferSize // or HKLM/Software/Microsoft/RAS Autodial/Default/DefaultInternet. // For Windows 2K: HKCU/RemoteAccess/InternetProfile. - const PRUnichar* key = nsnull; - const PRUnichar* val = nsnull; + char* key = nsnull; + char* val = nsnull; HKEY hKey = 0; LONG result = 0; @@ -545,10 +545,10 @@ nsresult nsRASAutodial::GetDefaultEntryName(PRUnichar* entryName, int bufferSize if ((mOSVerInfo.dwMajorVersion == 4) // Windows NT || ((mOSVerInfo.dwMajorVersion == 5) && (mOSVerInfo.dwMinorVersion == 0))) // Windows 2000 { - key = L"RemoteAccess"; - val = L"InternetProfile"; + key = "RemoteAccess"; + val = "InternetProfile"; - result = ::RegOpenKeyExW( + result = ::RegOpenKeyEx( HKEY_CURRENT_USER, key, 0, @@ -562,12 +562,12 @@ nsresult nsRASAutodial::GetDefaultEntryName(PRUnichar* entryName, int bufferSize } else // Windows XP { - key = L"Software\\Microsoft\\RAS Autodial\\Default"; - val = L"DefaultInternet"; + key = "Software\\Microsoft\\RAS Autodial\\Default"; + val = "DefaultInternet"; // Try HKCU first. - result = ::RegOpenKeyExW( + result = ::RegOpenKeyEx( HKEY_CURRENT_USER, key, 0, @@ -577,7 +577,7 @@ nsresult nsRASAutodial::GetDefaultEntryName(PRUnichar* entryName, int bufferSize if (result != ERROR_SUCCESS) { // If not present, try HKLM. - result = ::RegOpenKeyExW( + result = ::RegOpenKeyEx( HKEY_LOCAL_MACHINE, key, 0, @@ -595,7 +595,7 @@ nsresult nsRASAutodial::GetDefaultEntryName(PRUnichar* entryName, int bufferSize DWORD entryType = 0; DWORD buffSize = bufferSize; - result = ::RegQueryValueExW(hKey, + result = ::RegQueryValueEx(hKey, val, nsnull, &entryType, @@ -631,7 +631,7 @@ PRBool nsRASAutodial::IsAutodialServiceRunning() } SC_HANDLE hService = - OpenServiceW(hSCManager, L"RasAuto", SERVICE_QUERY_STATUS); + OpenService(hSCManager, "RasAuto", SERVICE_QUERY_STATUS); if (hSCManager == nsnull) { @@ -655,23 +655,23 @@ PRBool nsRASAutodial::IsAutodialServiceRunning() } // Add the specified address to the autodial directory. -PRBool nsRASAutodial::AddAddressToAutodialDirectory(const PRUnichar* hostName) +PRBool nsRASAutodial::AddAddressToAutodialDirectory(const char* hostName) { // Need to load the DLL if not loaded yet. if (!LoadRASapi32DLL()) return PR_FALSE; // First see if there is already a db entry for this address. - RASAUTODIALENTRYW autodialEntry; - autodialEntry.dwSize = sizeof(autodialEntry); - DWORD size = sizeof(autodialEntry); + RASAUTODIALENTRY autodialEntry; + autodialEntry.dwSize = sizeof(RASAUTODIALENTRY); + DWORD size = sizeof(RASAUTODIALENTRY); DWORD entries = 0; DWORD result = (*mpRasGetAutodialAddress)(hostName, - nsnull, - &autodialEntry, - &size, - &entries); + nsnull, + &autodialEntry, + &size, + &entries); // If there is already at least 1 entry in db for this address, return. if (result != ERROR_FILE_NOT_FOUND) @@ -680,16 +680,16 @@ PRBool nsRASAutodial::AddAddressToAutodialDirectory(const PRUnichar* hostName) return PR_FALSE; } - autodialEntry.dwSize = sizeof(autodialEntry); + autodialEntry.dwSize = sizeof(RASAUTODIALENTRY); autodialEntry.dwFlags = 0; autodialEntry.dwDialingLocation = mAutodialServiceDialingLocation; - GetDefaultEntryName(autodialEntry.szEntry, sizeof(autodialEntry.szEntry)); + GetDefaultEntryName(autodialEntry.szEntry, RAS_MaxEntryName); result = (*mpRasSetAutodialAddress)(hostName, - 0, - &autodialEntry, - sizeof(autodialEntry), - 1); + 0, + &autodialEntry, + sizeof(RASAUTODIALENTRY), + 1); if (result != ERROR_SUCCESS) { @@ -698,7 +698,7 @@ PRBool nsRASAutodial::AddAddressToAutodialDirectory(const PRUnichar* hostName) } LOGD(("Autodial: Added address %s to RAS autodial db for entry %s.", - hostName, NS_ConvertUTF16toUTF8(autodialEntry.szEntry).get())); + hostName, autodialEntry.szEntry)); return PR_TRUE; } @@ -707,9 +707,9 @@ PRBool nsRASAutodial::AddAddressToAutodialDirectory(const PRUnichar* hostName) int nsRASAutodial::GetCurrentLocation() { HKEY hKey = 0; - LONG result = ::RegOpenKeyExW( + LONG result = ::RegOpenKeyEx( HKEY_LOCAL_MACHINE, - L"Software\\Microsoft\\Windows\\CurrentVersion\\Telephony\\Locations", + "Software\\Microsoft\\Windows\\CurrentVersion\\Telephony\\Locations", 0, KEY_READ, &hKey); @@ -724,7 +724,7 @@ int nsRASAutodial::GetCurrentLocation() DWORD location = 0; DWORD paramSize = sizeof(DWORD); - result = ::RegQueryValueExW(hKey, L"CurrentID", nsnull, &entryType, (LPBYTE)&location, ¶mSize); + result = ::RegQueryValueEx(hKey, "CurrentID", nsnull, &entryType, (LPBYTE)&location, ¶mSize); if (result != ERROR_SUCCESS) { ::RegCloseKey(hKey); @@ -762,7 +762,7 @@ PRBool nsRASAutodial::LoadRASapi32DLL() { if (!mhRASapi32) { - mhRASapi32 = ::LoadLibraryW(L"rasapi32.dll"); + mhRASapi32 = ::LoadLibrary("rasapi32.dll"); if ((UINT)mhRASapi32 > 32) { // RasEnumConnections @@ -811,16 +811,16 @@ PRBool nsRASAutodial::LoadRASdlgDLL() { if (!mhRASdlg) { - mhRASdlg = ::LoadLibraryW(L"rasdlg.dll"); + mhRASdlg = ::LoadLibrary("rasdlg.dll"); if ((UINT)mhRASdlg > 32) { // RasPhonebookDlg mpRasPhonebookDlg = - (tRASPHONEBOOKDLG)::GetProcAddress(mhRASdlg, "RasPhonebookDlgW"); + (tRASPHONEBOOKDLG)::GetProcAddress(mhRASdlg, "RasPhonebookDlgA"); // RasDialDlg mpRasDialDlg = - (tRASDIALDLG)::GetProcAddress(mhRASdlg, "RasDialDlgW"); + (tRASDIALDLG)::GetProcAddress(mhRASdlg, "RasDialDlgA"); } } diff --git a/netwerk/base/src/nsAutodialWin.h b/netwerk/base/src/nsAutodialWin.h index 104136d191f6..36f7bc64dd41 100644 --- a/netwerk/base/src/nsAutodialWin.h +++ b/netwerk/base/src/nsAutodialWin.h @@ -52,21 +52,21 @@ typedef struct tagRASAUTODIALENTRYA { DWORD dwSize; DWORD dwFlags; DWORD dwDialingLocation; - PRUnichar szEntry[RAS_MaxEntryName + 1]; -} RASAUTODIALENTRYW, *LPRASAUTODIALENTRYW; -typedef RASAUTODIALENTRYW RASAUTODIALENTRY, *LPRASAUTODIALENTRY; + CHAR szEntry[RAS_MaxEntryName + 1]; +} RASAUTODIALENTRYA, *LPRASAUTODIALENTRYA; +typedef RASAUTODIALENTRYA RASAUTODIALENTRY, *LPRASAUTODIALENTRY; #define RASADP_LoginSessionDisable 1 #endif // WINVER // Loading the RAS DLL dynamically. -typedef DWORD (WINAPI* tRASPHONEBOOKDLG)(LPWSTR,LPWSTR,LPRASPBDLG); -typedef DWORD (WINAPI* tRASDIALDLG)(LPWSTR,LPWSTR,LPWSTR,LPRASDIALDLG); +typedef DWORD (WINAPI* tRASPHONEBOOKDLG)(LPTSTR,LPTSTR,LPRASPBDLG); +typedef DWORD (WINAPI* tRASDIALDLG)(LPTSTR,LPTSTR,LPTSTR,LPRASDIALDLG); typedef DWORD (WINAPI* tRASENUMCONNECTIONS)(LPRASCONN,LPDWORD,LPDWORD); -typedef DWORD (WINAPI* tRASENUMENTRIES)(LPWSTR,LPWSTR,LPRASENTRYNAMEW,LPDWORD,LPDWORD); -typedef DWORD (WINAPI* tRASSETAUTODIALADDRESS)(LPCWSTR,DWORD,LPRASAUTODIALENTRYW,DWORD,DWORD); -typedef DWORD (WINAPI* tRASGETAUTODIALADDRESS)(LPCWSTR,LPDWORD,LPRASAUTODIALENTRYW,LPDWORD,LPDWORD); +typedef DWORD (WINAPI* tRASENUMENTRIES)(LPTSTR,LPTSTR,LPRASENTRYNAME,LPDWORD,LPDWORD); +typedef DWORD (WINAPI* tRASSETAUTODIALADDRESS)(LPCTSTR,DWORD,LPRASAUTODIALENTRY,DWORD,DWORD); +typedef DWORD (WINAPI* tRASGETAUTODIALADDRESS)(LPCTSTR,LPDWORD,LPRASAUTODIALENTRY,LPDWORD,LPDWORD); typedef DWORD (WINAPI* tRASGETAUTODIALENABLE)(DWORD,LPBOOL); typedef DWORD (WINAPI* tRASGETAUTODIALPARAM)(DWORD,LPVOID,LPDWORD); // For Windows NT 4, 2000, and XP, we sometimes want to open the RAS dialup @@ -107,10 +107,10 @@ private: int NumRASEntries(); // Get the name of the default connection from the OS. - nsresult GetDefaultEntryName(PRUnichar* entryName, int bufferSize); + nsresult GetDefaultEntryName(char* entryName, int bufferSize); // Get the name of the first RAS dial entry from the OS. - nsresult GetFirstEntryName(PRUnichar* entryName, int bufferSize); + nsresult GetFirstEntryName(char* entryName, int bufferSize); // Check to see if RAS already has a dialup connection going. PRBool IsRASConnected(); @@ -119,7 +119,7 @@ private: int QueryAutodialBehavior(); // Add the specified address to the autodial directory. - PRBool AddAddressToAutodialDirectory(const PRUnichar* hostName); + PRBool AddAddressToAutodialDirectory(const char* hostName); // Get the current TAPI dialing location. int GetCurrentLocation(); @@ -145,7 +145,7 @@ private: int mNumRASConnectionEntries; // Default connection entry name. - PRUnichar mDefaultEntryName[RAS_MaxEntryName + 1]; + char mDefaultEntryName[RAS_MaxEntryName + 1]; // Don't try to dial again within a few seconds of when user pressed cancel. static PRIntervalTime mDontRetryUntil; @@ -184,7 +184,7 @@ public: nsresult Init(); // Dial the default RAS dialup connection. - nsresult DialDefault(const PRUnichar* hostName); + nsresult DialDefault(const char* hostName); // Should we try to dial on network error? PRBool ShouldDialOnNetworkError(); diff --git a/netwerk/base/src/nsNativeConnectionHelper.cpp b/netwerk/base/src/nsNativeConnectionHelper.cpp index 7d506b96f1ee..b528d0e87d40 100644 --- a/netwerk/base/src/nsNativeConnectionHelper.cpp +++ b/netwerk/base/src/nsNativeConnectionHelper.cpp @@ -44,7 +44,7 @@ PRBool -nsNativeConnectionHelper::OnConnectionFailed(const PRUnichar* hostName) +nsNativeConnectionHelper::OnConnectionFailed(const char* hostName) { nsRASAutodial autodial; diff --git a/netwerk/base/src/nsNativeConnectionHelper.h b/netwerk/base/src/nsNativeConnectionHelper.h index 86b1bf05827a..f86010786f4c 100644 --- a/netwerk/base/src/nsNativeConnectionHelper.h +++ b/netwerk/base/src/nsNativeConnectionHelper.h @@ -50,7 +50,7 @@ public: * * Return PR_TRUE if the connection should be re-attempted. */ - static PRBool OnConnectionFailed(const PRUnichar* hostName); + static PRBool OnConnectionFailed(const char* hostName); /** * IsAutoDialEnabled diff --git a/netwerk/base/src/nsSocketTransport2.cpp b/netwerk/base/src/nsSocketTransport2.cpp index 0c83db9cbcac..e81a367a78d9 100644 --- a/netwerk/base/src/nsSocketTransport2.cpp +++ b/netwerk/base/src/nsSocketTransport2.cpp @@ -1252,10 +1252,8 @@ nsSocketTransport::RecoverFromError() if (!tryAgain) { PRBool autodialEnabled; gSocketTransportService->GetAutodialEnabled(&autodialEnabled); - if (autodialEnabled) { - tryAgain = nsNativeConnectionHelper::OnConnectionFailed( - NS_ConvertUTF8toUTF16(SocketHost()).get()); - } + if (autodialEnabled) + tryAgain = nsNativeConnectionHelper::OnConnectionFailed(SocketHost().get()); } #endif diff --git a/netwerk/protocol/file/src/nsFileProtocolHandler.cpp b/netwerk/protocol/file/src/nsFileProtocolHandler.cpp index 9c81bc050e73..0578c7806bd3 100644 --- a/netwerk/protocol/file/src/nsFileProtocolHandler.cpp +++ b/netwerk/protocol/file/src/nsFileProtocolHandler.cpp @@ -114,22 +114,23 @@ nsFileProtocolHandler::ReadURLFile(nsIFile* aFile, nsIURI** aURI) rv = NS_ERROR_NOT_AVAILABLE; - IUniformResourceLocatorW* urlLink = nsnull; + IUniformResourceLocator* urlLink = nsnull; result = ::CoCreateInstance(CLSID_InternetShortcut, NULL, CLSCTX_INPROC_SERVER, - IID_IUniformResourceLocatorW, (void**)&urlLink); + IID_IUniformResourceLocator, (void**)&urlLink); if (SUCCEEDED(result) && urlLink) { IPersistFile* urlFile = nsnull; result = urlLink->QueryInterface(IID_IPersistFile, (void**)&urlFile); if (SUCCEEDED(result) && urlFile) { result = urlFile->Load(path.get(), STGM_READ); if (SUCCEEDED(result) ) { - LPWSTR lpTemp = nsnull; + LPSTR lpTemp = nsnull; // The URL this method will give us back seems to be already // escaped. Hence, do not do escaping of our own. result = urlLink->GetURL(&lpTemp); if (SUCCEEDED(result) && lpTemp) { - rv = NS_NewURI(aURI, NS_ConvertUTF16toUTF8(lpTemp)); + rv = NS_NewURI(aURI, lpTemp); + // free the string that GetURL alloc'd CoTaskMemFree(lpTemp); } diff --git a/netwerk/system/win32/nsNotifyAddrListener.cpp b/netwerk/system/win32/nsNotifyAddrListener.cpp index 1a6a247faaef..eb8b0a8e0d7b 100644 --- a/netwerk/system/win32/nsNotifyAddrListener.cpp +++ b/netwerk/system/win32/nsNotifyAddrListener.cpp @@ -75,7 +75,7 @@ static void InitIPHelperLibrary(void) if (sIPHelper) return; - sIPHelper = LoadLibraryW(L"iphlpapi.dll"); + sIPHelper = LoadLibraryA("iphlpapi.dll"); if (!sIPHelper) return;