Fix 26486

This commit is contained in:
ruslan%netscape.com 2000-05-26 20:12:50 +00:00
parent 818e9366ff
commit e83b37e98a
4 changed files with 71 additions and 10 deletions

View File

@ -44,6 +44,7 @@ static NS_DEFINE_CID(kSocketProviderService, NS_SOCKETPROVIDERSERVICE_CID);
static NS_DEFINE_CID(kDNSService, NS_DNSSERVICE_CID);
static NS_DEFINE_CID(kProxyObjectManagerCID, NS_PROXYEVENT_MANAGER_CID);
static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
//
// This is the State table which maps current state to next state
// for each socket operation...
@ -306,7 +307,7 @@ nsresult nsSocketTransport::Init(nsSocketTransportService* aService,
PR_LOG(gSocketLog, PR_LOG_DEBUG,
("Initializing nsSocketTransport [%s:%d %x]. rv = %x",
mHostName, mPort, this, rv));
return rv;
}
@ -2398,9 +2399,8 @@ nsSocketTransport::GetSocketErrorString(PRUint32 iCode,
case eSocketState_Created:
case eSocketState_WaitDNS:
{
// STRING USE WARNING: this needs to be looked at -- scc
static nsAutoString mesg; mesg.AssignWithConversion("Resolving host ");
*oString = mesg.ToNewUnicode();
// STRING USE WARNING: this needs to be looked at -- scc
mService -> GetNeckoStringByName ("ResolvingHost", oString);
if (!*oString) return NS_ERROR_OUT_OF_MEMORY;
rv = NS_OK;
}
@ -2408,8 +2408,7 @@ nsSocketTransport::GetSocketErrorString(PRUint32 iCode,
case eSocketState_Connected:
{
// STRING USE WARNING: this needs to be looked at -- scc
static nsAutoString mesg; mesg.AssignWithConversion("Connected to ");
*oString = mesg.ToNewUnicode();
mService -> GetNeckoStringByName ("ConnectedTo", oString);
if (!*oString) return NS_ERROR_OUT_OF_MEMORY;
rv = NS_OK;
}
@ -2419,8 +2418,11 @@ nsSocketTransport::GetSocketErrorString(PRUint32 iCode,
// STRING USE WARNING: this needs to be looked at -- scc
static nsAutoString frommesg; frommesg.AssignWithConversion("Transferring data from ");
static nsAutoString tomesg; tomesg.AssignWithConversion("Sending request to ");
*oString = (mWriteContext == nsnull) ?
frommesg.ToNewUnicode() : tomesg.ToNewUnicode();
if (mWriteContext == nsnull)
mService -> GetNeckoStringByName ("SendingRequestTo", oString);
else
mService -> GetNeckoStringByName ("TransferringDataFrom", oString);
if (!*oString) return NS_ERROR_OUT_OF_MEMORY;
rv = NS_OK;
}
@ -2428,8 +2430,7 @@ nsSocketTransport::GetSocketErrorString(PRUint32 iCode,
case eSocketState_WaitConnect:
{
// STRING USE WARNING: this needs to be looked at -- scc
static nsAutoString mesg; mesg.AssignWithConversion("Connecting to ");
*oString = mesg.ToNewUnicode();
mService -> GetNeckoStringByName ("ConnectingTo", oString);
if (!*oString) return NS_ERROR_OUT_OF_MEMORY;
rv = NS_OK;
}

View File

@ -28,8 +28,10 @@
#include "nsAutoLock.h"
#include "nsIIOService.h"
#include "nsIServiceManager.h"
#include "nsString.h"
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
nsSocketTransportService::nsSocketTransportService () :
mConnectedTransports (0),
@ -650,3 +652,49 @@ nsSocketTransportService::GetInUseTransportCount (PRUint32 * o_TransCount)
*o_TransCount = (PRUint32) mSelectFDSetCount;
return NS_OK;
}
nsresult
nsSocketTransportService::GetNeckoStringByName (const char *aName, PRUnichar **aString)
{
nsresult res;
nsAutoString resultString; resultString.AssignWithConversion(aName);
if (!m_stringBundle)
{
char* propertyURL = NECKO_MSGS_URL;
NS_WITH_SERVICE(nsIStringBundleService, sBundleService, kStringBundleServiceCID, &res);
if (NS_SUCCEEDED (res) && (nsnull != sBundleService))
{
nsILocale *locale = nsnull;
res = sBundleService->CreateBundle(propertyURL, locale, getter_AddRefs(m_stringBundle));
}
}
if (m_stringBundle)
{
nsAutoString unicodeName; unicodeName.AssignWithConversion(aName);
PRUnichar *ptrv = nsnull;
res = m_stringBundle->GetStringFromName(unicodeName.GetUnicode(), &ptrv);
if (NS_FAILED(res))
{
resultString.AssignWithConversion("[StringName");
resultString.AppendWithConversion(aName);
resultString.AppendWithConversion("?]");
*aString = resultString.ToNewUnicode();
}
else
{
*aString = ptrv;
}
}
else
{
res = NS_OK;
*aString = resultString.ToNewUnicode();
}
return res;
}

View File

@ -28,6 +28,8 @@
#include "nsIThread.h"
#include "nsISocketTransportService.h"
#include "nsIInputStream.h"
#include "nsCOMPtr.h"
#include "nsIStringBundle.h"
#if defined(XP_PC) || defined(XP_UNIX) || defined(XP_BEOS)
//
@ -45,6 +47,7 @@
#define MAX_OPEN_CONNECTIONS 50
#define DEFAULT_POLL_TIMEOUT_IN_MS 35*1000
#define NECKO_MSGS_URL "chrome://necko/locale/necko.properties"
// Forward declarations...
class nsSocketTransport;
@ -79,6 +82,8 @@ public:
PRInt32 mConnectedTransports;
PRInt32 mTotalTransports;
nsresult GetNeckoStringByName (const char *aName, PRUnichar **aString);
protected:
nsIThread* mThread;
PRFileDesc* mThreadEvent;
@ -90,6 +95,7 @@ protected:
PRInt32 mSelectFDSetCount;
PRPollDesc* mSelectFDSet;
nsSocketTransport** mActiveTransportList;
nsCOMPtr<nsIStringBundle> m_stringBundle;
};

View File

@ -18,3 +18,9 @@
# Contributor(s):
#
# downloadHeadersTitlePrefix=Download headers for:
ResolvingHost=Resolving host
ConnectedTo=Connected to
ConnectingTo=Connecting to
SendingRequestTo=Sending request to
TransferringDataFrom=Transferring data from