Move nsCString from |operator char*()| to |get()| and |NS_CONST_CAST| where needed. bug=53057, r=dmose, sr=shaver

This commit is contained in:
disttsc%bart.nl 2001-03-20 05:37:56 +00:00
Родитель e7dd8a9127
Коммит 0b98c23d64
25 изменённых файлов: 55 добавлений и 834 удалений

Просмотреть файл

@ -629,8 +629,8 @@ nsPSMComponent::GetControlConnection( CMT_CONTROL * *_retval )
psmStatus = CMT_Hello( mControl,
PROTOCOL_VERSION,
profilenameC,
NS_CONST_CAST(char*,(const char*)profilePath));
NS_CONST_CAST(char*,profilenameC.get()),
NS_CONST_CAST(char*,profilePath.get()));
if (psmStatus == CMTFailure)
goto failure;

Просмотреть файл

@ -1,756 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nspr.h"
#include "nsString.h"
#include "cmtcmn.h"
#include "nsIPSMComponent.h"
#include "nsIPSMSocketInfo.h"
#include "nsIServiceManager.h"
#include "nsPSMShimLayer.h"
#include "nsSSLIOLayer.h"
#include "nsIWebProgressListener.h"
#include "nsISSLSocketControl.h"
#include "nsIInterfaceRequestor.h"
static PRDescIdentity nsSSLIOLayerIdentity;
static PRIOMethods nsSSLIOLayerMethods;
static nsIPSMComponent* gPSMService = nsnull;
static PRBool firstTime = PR_TRUE;
class nsPSMSocketInfo : public nsIPSMSocketInfo,
public nsISSLSocketControl
{
public:
nsPSMSocketInfo();
virtual ~nsPSMSocketInfo();
NS_DECL_ISUPPORTS
NS_DECL_NSITRANSPORTSECURITYINFO
NS_DECL_NSIPSMSOCKETINFO
NS_DECL_NSISSLSOCKETCONTROL
// internal functions to psm-glue.
nsresult SetSocketPtr(CMSocket *socketPtr);
nsresult SetControlPtr(CMT_CONTROL *aControlPtr);
nsresult SetFileDescPtr(PRFileDesc *aControlPtr);
nsresult SetHostName(const char *aHostName);
nsresult SetProxyName(const char *aName);
nsresult SetHostPort(PRInt32 aPort);
nsresult SetProxyPort(PRInt32 aPort);
nsresult SetPickledStatus();
nsresult SetUseTLS(PRBool useTLS);
nsresult GetUseTLS(PRBool *useTLS);
protected:
CMT_CONTROL* mControl;
CMSocket* mSocket;
PRFileDesc* mFd;
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
nsString mHostName;
PRInt32 mHostPort;
nsString mProxyName;
PRInt32 mProxyPort;
PRBool mForceHandshake;
PRBool mUseTLS;
unsigned char* mPickledStatus;
};
static PRStatus PR_CALLBACK
nsSSLIOLayerConnect(PRFileDesc *fd, const PRNetAddr *addr, PRIntervalTime timeout)
{
nsresult result;
PRStatus rv = PR_SUCCESS;
CMTStatus status = CMTFailure;
/* Set the error in case of failure. */
PR_SetError(PR_UNKNOWN_ERROR, status);
if (!fd || !addr || !fd->secret || !gPSMService)
return PR_FAILURE;
char ipBuffer[PR_NETDB_BUF_SIZE];
rv = PR_NetAddrToString(addr, (char*)&ipBuffer, PR_NETDB_BUF_SIZE);
if (rv != PR_SUCCESS)
return PR_FAILURE;
if (addr->raw.family == PR_AF_INET6 && PR_IsNetAddrType(addr, PR_IpAddrV4Mapped))
{
/* Chop off the leading "::ffff:" */
strcpy(ipBuffer, ipBuffer + 7);
}
CMT_CONTROL *control;
result = gPSMService->GetControlConnection(&control);
if (result != PR_SUCCESS)
return PR_FAILURE;
CMSocket* cmsock = (CMSocket *)PR_Malloc(sizeof(CMSocket));
if (!cmsock)
return PR_FAILURE;
memset(cmsock, 0, sizeof(CMSocket));
cmsock->fd = fd->lower;
cmsock->isUnix = PR_FALSE;
nsPSMSocketInfo *infoObject = (nsPSMSocketInfo *)fd->secret;
infoObject->SetControlPtr(control);
infoObject->SetSocketPtr(cmsock);
char* proxyName;
char* hostName;
PRInt32 proxyPort;
PRInt32 hostPort;
PRBool forceHandshake;
PRBool useTLS;
infoObject->GetProxyName(&proxyName);
infoObject->GetHostName(&hostName);
infoObject->GetProxyPort(&proxyPort);
infoObject->GetHostPort(&hostPort);
infoObject->GetForceHandshake(&forceHandshake);
infoObject->GetUseTLS(&useTLS);
if (proxyName)
{
PRInt32 destPort;
infoObject->GetProxyPort(&destPort);
status = CMT_OpenSSLProxyConnection(control,
cmsock,
destPort,
// we assume that we were called
// with the addr of the proxy host
ipBuffer,
proxyName);
}
else if (useTLS)
{
status = CMT_OpenTLSConnection(control,
cmsock,
PR_ntohs(addr->inet.port),
ipBuffer,
(hostName ? hostName : ipBuffer));
}
else
{
CMBool handshake = forceHandshake ? CM_TRUE : CM_FALSE;
// Direct connection
status = CMT_OpenSSLConnection(control,
cmsock,
SSM_REQUEST_SSL_DATA_SSL,
PR_ntohs(addr->inet.port),
ipBuffer,
(hostName ? hostName : ipBuffer),
handshake,
infoObject);
}
if (hostName) Recycle(hostName);
if (proxyName) Recycle(proxyName);
if (CMTSuccess == status)
{
PRSocketOptionData sockopt;
sockopt.option = PR_SockOpt_Nonblocking;
rv = PR_GetSocketOption(fd, &sockopt);
if (PR_SUCCESS == rv && !sockopt.value.non_blocking) {
// this is a nonblocking socket, so we can return success
return PR_SUCCESS;
}
// since our stuff can block, what we want to do is return PR_FAILURE,
// but set the nspr ERROR to BLOCK. This will put us into a select
// q.
PR_SetError(PR_WOULD_BLOCK_ERROR, status);
return PR_FAILURE;
}
return PR_FAILURE;
}
/* CMT_DestroyDataConnection(ctrl, sock); */
/* need to strip our layer, pass result to DestroyDataConnection */
/* which will clean up the CMT accounting of sock, then call our */
/* shim layer to translate back to NSPR */
static PRStatus PR_CALLBACK
nsSSLIOLayerClose(PRFileDesc *fd)
{
nsPSMSocketInfo *infoObject = (nsPSMSocketInfo *)fd->secret;
PRDescIdentity id = PR_GetLayersIdentity(fd);
if (infoObject && id == nsSSLIOLayerIdentity)
{
CMInt32 errorCode = PR_FAILURE;
CMT_CONTROL* control;
CMSocket* sock;
PR_Shutdown(fd, PR_SHUTDOWN_BOTH);
infoObject->GetControlPtr(&control);
infoObject->GetSocketPtr(&sock);
/*
* was infoObject->SetPickledStatus();
* The PSM code decrements the refcount on the SSL state
* whenever it is asked for the pickled status. Until we
* get a PSM protocol change implemented, we have to avoid
* asking for the pickled status twice on the same connection.
* --jgmyers
*/
infoObject->GetPickledStatus(nsnull);
CMT_GetSSLDataErrorCode(control, sock, &errorCode);
CMT_DestroyDataConnection(control, sock);
NS_RELEASE(infoObject); // if someone is interested in us, the better have an addref.
fd->identity = PR_INVALID_IO_LAYER;
return (PRStatus)errorCode;
}
return PR_FAILURE;
}
static PRInt32 PR_CALLBACK
nsSSLIOLayerRead( PRFileDesc *fd, void *buf, PRInt32 amount)
{
if (!fd)
return PR_FAILURE;
PRInt32 result = PR_Recv(fd, buf, amount, 0, PR_INTERVAL_MIN);
if (result > 0)
return result;
if (result == -1)
{
PRErrorCode code = PR_GetError();
if (code == PR_IO_TIMEOUT_ERROR )
PR_SetError(PR_WOULD_BLOCK_ERROR, PR_WOULD_BLOCK_ERROR);
return PR_FAILURE;
}
if (result == 0)
{
nsPSMSocketInfo *infoObject = (nsPSMSocketInfo *)fd->secret;
PRDescIdentity id = PR_GetLayersIdentity(fd);
if (infoObject && id == nsSSLIOLayerIdentity)
{
CMInt32 errorCode = PR_FAILURE;
CMT_CONTROL* control;
CMSocket* sock;
infoObject->GetControlPtr(&control);
infoObject->GetSocketPtr(&sock);
CMT_GetSSLDataErrorCode(control, sock, &errorCode);
if (errorCode == PR_IO_TIMEOUT_ERROR)
{
PR_SetError(PR_WOULD_BLOCK_ERROR, PR_WOULD_BLOCK_ERROR);
return PR_FAILURE;
}
PR_SetError(0, 0);
return errorCode;
}
}
return result;
}
static PRInt32 PR_CALLBACK
nsSSLIOLayerWrite( PRFileDesc *fd, const void *buf, PRInt32 amount)
{
if (!fd)
return PR_FAILURE;
PRInt32 result = PR_Send(fd, buf, amount, 0, PR_INTERVAL_MIN);
if (result > 0)
return result;
if (result == -1)
{
PRErrorCode code = PR_GetError();
if (code == PR_IO_TIMEOUT_ERROR )
PR_SetError(PR_WOULD_BLOCK_ERROR, PR_WOULD_BLOCK_ERROR);
return PR_FAILURE;
}
if (result == 0)
{
nsPSMSocketInfo *infoObject = (nsPSMSocketInfo *)fd->secret;
PRDescIdentity id = PR_GetLayersIdentity(fd);
if (infoObject && id == nsSSLIOLayerIdentity)
{
CMInt32 errorCode = PR_FAILURE;
CMT_CONTROL* control;
CMSocket* sock;
infoObject->GetControlPtr(&control);
infoObject->GetSocketPtr(&sock);
CMT_GetSSLDataErrorCode(control, sock, &errorCode);
PR_SetError(0, 0);
return errorCode;
}
}
return result;
}
nsPSMSocketInfo::nsPSMSocketInfo()
{
NS_INIT_REFCNT();
mControl = nsnull;
mSocket = nsnull;
mPickledStatus = nsnull;
mForceHandshake = PR_FALSE;
mUseTLS = PR_FALSE;
}
nsPSMSocketInfo::~nsPSMSocketInfo()
{
PR_FREEIF(mPickledStatus);
}
NS_IMPL_THREADSAFE_ISUPPORTS3(nsPSMSocketInfo, nsITransportSecurityInfo,
nsIPSMSocketInfo, nsISSLSocketControl);
// if the connection was via a proxy, we need to have the
// ssl layer "step up" to take an active role in the connection
NS_IMETHODIMP
nsPSMSocketInfo::ProxyStepUp()
{
nsCAutoString hostName;
hostName.AssignWithConversion(mHostName);
return CMT_ProxyStepUp(mControl, mSocket, this, hostName);
}
NS_IMETHODIMP
nsPSMSocketInfo::TLSStepUp()
{
return CMT_TLSStepUp(mControl, mSocket, this);
}
NS_IMETHODIMP
nsPSMSocketInfo::GetControlPtr(CMT_CONTROL * *aControlPtr)
{
*aControlPtr = mControl;
return NS_OK;
}
nsresult
nsPSMSocketInfo::SetControlPtr(CMT_CONTROL *aControlPtr)
{
mControl = aControlPtr;
return NS_OK;
}
NS_IMETHODIMP
nsPSMSocketInfo::GetSocketPtr(CMSocket * *socketPtr)
{
*socketPtr = mSocket;
return NS_OK;
}
nsresult
nsPSMSocketInfo::SetSocketPtr(CMSocket *socketPtr)
{
mSocket = socketPtr;
return NS_OK;
}
NS_IMETHODIMP
nsPSMSocketInfo::GetFileDescPtr(PRFileDesc * *aFilePtr)
{
*aFilePtr = mFd;
return NS_OK;
}
nsresult
nsPSMSocketInfo::SetFileDescPtr(PRFileDesc *aFilePtr)
{
mFd = aFilePtr;
return NS_OK;
}
NS_IMETHODIMP
nsPSMSocketInfo::GetHostName(char * *aHostName)
{
if (mHostName.IsEmpty())
*aHostName = nsnull;
else
*aHostName = mHostName.ToNewCString();
return NS_OK;
}
nsresult
nsPSMSocketInfo::SetHostName(const char *aHostName)
{
mHostName.AssignWithConversion(aHostName);
return NS_OK;
}
NS_IMETHODIMP
nsPSMSocketInfo::GetHostPort(PRInt32 *aPort)
{
*aPort = mHostPort;
return NS_OK;
}
nsresult
nsPSMSocketInfo::SetHostPort(PRInt32 aPort)
{
mHostPort = aPort;
return NS_OK;
}
NS_IMETHODIMP
nsPSMSocketInfo::GetProxyName(char * *aName)
{
if (mProxyName.IsEmpty())
*aName = nsnull;
else
*aName = mProxyName.ToNewCString();
return NS_OK;
}
nsresult
nsPSMSocketInfo::SetProxyName(const char *aName)
{
mProxyName.AssignWithConversion(aName);
return NS_OK;
}
NS_IMETHODIMP
nsPSMSocketInfo::GetProxyPort(PRInt32 *aPort)
{
*aPort = mProxyPort;
return NS_OK;
}
nsresult
nsPSMSocketInfo::SetProxyPort(PRInt32 aPort)
{
mProxyPort = aPort;
return NS_OK;
}
NS_IMETHODIMP
nsPSMSocketInfo::GetForceHandshake(PRBool *forceHandshake)
{
*forceHandshake = mForceHandshake;
return NS_OK;
}
NS_IMETHODIMP
nsPSMSocketInfo::SetForceHandshake(PRBool forceHandshake)
{
mForceHandshake = forceHandshake;
return NS_OK;
}
nsresult
nsPSMSocketInfo::GetUseTLS(PRBool *aResult)
{
*aResult = mUseTLS;
return NS_OK;
}
nsresult
nsPSMSocketInfo::SetUseTLS(PRBool useTLS)
{
mUseTLS = useTLS;
return NS_OK;
}
nsresult
nsPSMSocketInfo::GetShortSecurityDescription(PRUnichar** aText)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
nsPSMSocketInfo::SetPickledStatus()
{
PR_FREEIF(mPickledStatus);
long level;
CMTItem pickledStatus = {0, nsnull, 0};
unsigned char* ret = nsnull;
if (NS_SUCCEEDED(CMT_GetSSLSocketStatus(mControl, mSocket, &pickledStatus, &level)))
{
ret = (unsigned char*) PR_Malloc( (SSMSTRING_PADDED_LENGTH(pickledStatus.len) + sizeof(int)) );
if (ret)
{
*(int*)ret = pickledStatus.len;
memcpy(ret+sizeof(int), pickledStatus.data, *(int*)ret);
}
PR_FREEIF(pickledStatus.data);
mPickledStatus = ret;
}
return NS_OK;
}
NS_IMETHODIMP
nsPSMSocketInfo::GetPickledStatus(char * *pickledStatusString)
{
if (!mPickledStatus)
SetPickledStatus();
if (mPickledStatus)
{
if (pickledStatusString) {
PRInt32 len = *(int*)mPickledStatus + sizeof(int);
char *out = (char *)nsMemory::Alloc(len);
memcpy(out, mPickledStatus, len);
*pickledStatusString = out;
}
return NS_OK;
}
if (pickledStatusString) {
*pickledStatusString = nsnull;
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsPSMSocketInfo::GetSecurityState(PRInt32 *aSecurityState)
{
if (!mPickledStatus)
SetPickledStatus();
*aSecurityState = mPickledStatus ? (PRInt32) nsIWebProgressListener::STATE_IS_SECURE
: (PRInt32) nsIWebProgressListener::STATE_IS_BROKEN;
return NS_OK;
}
NS_IMETHODIMP
nsPSMSocketInfo::GetNotificationCallbacks(nsIInterfaceRequestor** aCallbacks)
{
*aCallbacks = mCallbacks;
NS_IF_ADDREF(*aCallbacks);
return NS_OK;
}
NS_IMETHODIMP
nsPSMSocketInfo::SetNotificationCallbacks(nsIInterfaceRequestor* aCallbacks)
{
mCallbacks = aCallbacks;
return NS_OK;
}
nsresult
nsSSLIOLayerNewSocket( const char *host,
PRInt32 port,
const char *proxyHost,
PRInt32 proxyPort,
PRFileDesc **fd,
nsISupports** info,
PRBool useTLS)
{
if (firstTime)
{
nsSSLIOLayerIdentity = PR_GetUniqueIdentity("Cartman layer");
nsSSLIOLayerMethods = *PR_GetDefaultIOMethods();
nsSSLIOLayerMethods.connect = nsSSLIOLayerConnect;
nsSSLIOLayerMethods.close = nsSSLIOLayerClose;
nsSSLIOLayerMethods.read = nsSSLIOLayerRead;
nsSSLIOLayerMethods.write = nsSSLIOLayerWrite;
nsresult result = nsServiceManager::GetService( PSM_COMPONENT_CONTRACTID,
NS_GET_IID(nsIPSMComponent),
(nsISupports**)&gPSMService);
if (NS_FAILED(result))
return PR_FAILURE;
firstTime = PR_FALSE;
}
PRFileDesc * sock;
PRFileDesc * layer;
PRStatus rv;
/* Get a normal NSPR socket */
sock = PR_NewTCPSocket();
if (! sock) return NS_ERROR_OUT_OF_MEMORY;
/* disable Nagle algorithm delay for control sockets */
PRSocketOptionData sockopt;
sockopt.option = PR_SockOpt_NoDelay;
sockopt.value.no_delay = PR_TRUE;
rv = PR_SetSocketOption(sock, &sockopt);
PR_ASSERT(PR_SUCCESS == rv);
layer = PR_CreateIOLayerStub(nsSSLIOLayerIdentity, &nsSSLIOLayerMethods);
if (! layer)
{
PR_Close(sock);
return NS_ERROR_FAILURE;
}
nsPSMSocketInfo * infoObject = new nsPSMSocketInfo();
if (!infoObject)
{
PR_Close(sock);
// clean up IOLayerStub.
PR_DELETE(layer);
return NS_ERROR_FAILURE;
}
NS_ADDREF(infoObject);
infoObject->SetHostName(host);
infoObject->SetHostPort(port);
infoObject->SetProxyName(proxyHost);
infoObject->SetProxyPort(proxyPort);
infoObject->SetUseTLS(useTLS);
layer->secret = (PRFilePrivate*) infoObject;
rv = PR_PushIOLayer(sock, PR_GetLayersIdentity(sock), layer);
if (NS_FAILED(rv))
{
PR_Close(sock);
NS_RELEASE(infoObject);
PR_DELETE(layer);
return NS_ERROR_FAILURE;
}
*fd = sock;
infoObject->QueryInterface(NS_GET_IID(nsISupports), (void**) info);
return NS_OK;
}
nsresult
nsSSLIOLayerAddToSocket( const char *host,
PRInt32 port,
const char *proxyHost,
PRInt32 proxyPort,
PRFileDesc *fd,
nsISupports** info,
PRBool useTLS)
{
if (firstTime)
{
nsSSLIOLayerIdentity = PR_GetUniqueIdentity("Cartman layer");
nsSSLIOLayerMethods = *PR_GetDefaultIOMethods();
nsSSLIOLayerMethods.connect = nsSSLIOLayerConnect;
nsSSLIOLayerMethods.close = nsSSLIOLayerClose;
nsSSLIOLayerMethods.read = nsSSLIOLayerRead;
nsSSLIOLayerMethods.write = nsSSLIOLayerWrite;
nsresult result = nsServiceManager::GetService( PSM_COMPONENT_CONTRACTID,
NS_GET_IID(nsIPSMComponent),
(nsISupports**)&gPSMService);
if (NS_FAILED(result))
return PR_FAILURE;
firstTime = PR_FALSE;
}
PRFileDesc * layer;
PRStatus rv;
/* disable Nagle algorithm delay for control sockets */
PRSocketOptionData sockopt;
sockopt.option = PR_SockOpt_NoDelay;
sockopt.value.no_delay = PR_TRUE;
rv = PR_SetSocketOption(fd, &sockopt);
PR_ASSERT(PR_SUCCESS == rv);
layer = PR_CreateIOLayerStub(nsSSLIOLayerIdentity, &nsSSLIOLayerMethods);
if (! layer)
{
return NS_ERROR_FAILURE;
}
nsPSMSocketInfo * infoObject = new nsPSMSocketInfo();
if (!infoObject)
{
// clean up IOLayerStub.
PR_DELETE(layer);
return NS_ERROR_FAILURE;
}
NS_ADDREF(infoObject);
infoObject->SetHostName(host);
infoObject->SetHostPort(port);
infoObject->SetProxyName(proxyHost);
infoObject->SetProxyPort(proxyPort);
infoObject->SetUseTLS(useTLS);
layer->secret = (PRFilePrivate*) infoObject;
rv = PR_PushIOLayer(fd, PR_GetLayersIdentity(fd), layer);
if (NS_FAILED(rv))
{
NS_RELEASE(infoObject);
PR_DELETE(layer);
return rv;
}
infoObject->QueryInterface(NS_GET_IID(nsISupports), (void**) info);
return NS_OK;
}

Просмотреть файл

@ -2515,7 +2515,7 @@ nsFontMetricsGTK::SearchNode(nsFontNode* aNode, PRUnichar aChar)
}
static void
GetFontNames(char* aPattern, nsFontNodeArray* aNodes)
GetFontNames(const char* aPattern, nsFontNodeArray* aNodes)
{
#ifdef NS_FONT_DEBUG_CALL_TRACE
if (gDebug & NS_FONT_DEBUG_CALL_TRACE) {
@ -2873,7 +2873,7 @@ nsFontMetricsGTK::TryNode(nsCString* aName, PRUnichar aChar)
hyphen = pattern.FindChar('-', PR_FALSE, hyphen + 1);
pattern.Insert("-*-*-*-*-*-*-*-*-*-*", hyphen);
nsFontNodeArray nodes;
GetFontNames(pattern, &nodes);
GetFontNames(pattern.get(), &nodes);
if (nodes.Count() > 0) {
node = nodes.GetElement(0);
}

Просмотреть файл

@ -102,7 +102,7 @@ NS_IMPL_ISUPPORTS1(nsAddbookUrl, nsIURI)
// addbook:add?vcard=begin%3Avcard%0Afn%3ARichard%20Pizzarro%0Aemail%3Binternet%3Arhp%40netscape.com%0Aend%3Avcard%0A
//
NS_IMETHODIMP
nsAddbookUrl::CrackAddURL(char *searchPart)
nsAddbookUrl::CrackAddURL(const char *searchPart)
{
return NS_OK;
}
@ -115,12 +115,12 @@ nsAddbookUrl::CrackAddURL(char *searchPart)
// addbook:printall?email=rhp@netscape.com&folder=Netscape%20Address%20Book
//
NS_IMETHODIMP
nsAddbookUrl::CrackPrintURL(char *searchPart, PRInt32 aOperation)
nsAddbookUrl::CrackPrintURL(const char *searchPart, PRInt32 aOperation)
{
nsCString emailAddr;
nsCString folderName;
char *rest = searchPart;
char *rest = NS_CONST_CAST(char*, searchPart);
// okay, first, free up all of our old search part state.....
CleanupAddbookState();
@ -166,13 +166,13 @@ nsAddbookUrl::CrackPrintURL(char *searchPart, PRInt32 aOperation)
if (!emailAddr.IsEmpty())
{
nsUnescape(emailAddr);
nsUnescape(NS_CONST_CAST(char*, emailAddr.get()));
mAbCardProperty->SetCardValue(kPriEmailColumn, NS_ConvertASCIItoUCS2(emailAddr).GetUnicode());
}
if (!folderName.IsEmpty())
{
nsUnescape(folderName);
nsUnescape(NS_CONST_CAST(char*, folderName.get()));
mAbCardProperty->SetCardValue(kWorkAddressBook, NS_ConvertASCIItoUCS2(folderName).GetUnicode());
}
@ -256,7 +256,7 @@ nsresult nsAddbookUrl::ParseUrl()
}
else if (!mOperationPart.IsEmpty())
{
nsUnescape(mOperationPart);
nsUnescape(NS_CONST_CAST(char*, mOperationPart.get()));
}
mOperationPart.ToLowerCase();
@ -264,17 +264,17 @@ nsresult nsAddbookUrl::ParseUrl()
if (!nsCRT::strcmp(mOperationPart, "printone"))
{
mOperationType = nsIAddbookUrlOperation::PrintIndividual;
rv = CrackPrintURL(searchPart, mOperationType);
rv = CrackPrintURL(searchPart.get(), mOperationType);
}
else if (!nsCRT::strcmp(mOperationPart, "printall"))
{
mOperationType = nsIAddbookUrlOperation::PrintAddressBook;
rv = CrackPrintURL(searchPart, mOperationType);
rv = CrackPrintURL(searchPart.get(), mOperationType);
}
else if (!nsCRT::strcmp(mOperationPart, "add"))
{
mOperationType = nsIAddbookUrlOperation::AddToAddressBook;
rv = CrackAddURL(searchPart);
rv = CrackAddURL(searchPart.get());
}
else
mOperationType = nsIAddbookUrlOperation::InvalidUrl;

Просмотреть файл

@ -48,8 +48,8 @@ protected:
nsresult ParseUrl(); // This gets the ball rolling...
NS_METHOD CrackAddURL(char *searchPart);
NS_METHOD CrackPrintURL(char *searchPart, PRInt32 aOperation);
NS_METHOD CrackAddURL(const char *searchPart);
NS_METHOD CrackPrintURL(const char *searchPart, PRInt32 aOperation);
NS_METHOD GetAbCardProperty(nsAbCardProperty **aAbCardProp);
nsCString mOperationPart; // string name of operation requested

Просмотреть файл

@ -1323,7 +1323,7 @@ NS_IMETHODIMP QuotingOutputStreamListener::OnStopRequest(nsIRequest *request, ns
addressToBeRemoved += NS_CONST_CAST(char*, (const char *)email);
}
rv= RemoveDuplicateAddresses(_compFields->GetCc(), (char *)addressToBeRemoved, PR_TRUE, &resultStr);
rv= RemoveDuplicateAddresses(_compFields->GetCc(), addressToBeRemoved.get(), PR_TRUE, &resultStr);
if (NS_SUCCEEDED(rv))
{
_compFields->SetCc(resultStr);
@ -2212,7 +2212,7 @@ nsresult nsMsgCompose::NotifyStateListeners(TStateListenerNotification aNotifica
nsresult nsMsgCompose::AttachmentPrettyName(const char* url, PRUnichar** _retval)
{
nsCAutoString unescapeURL(url);
nsUnescape(unescapeURL);
nsUnescape(NS_CONST_CAST(char*, unescapeURL.get()));
if (unescapeURL.IsEmpty())
{
nsAutoString unicodeUrl;

Просмотреть файл

@ -170,21 +170,21 @@ nsresult nsMailtoUrl::ParseMailtoUrl(char * searchPart)
// Now unescape any fields that need escaped...
if (!m_toPart.IsEmpty())
nsUnescape(m_toPart);
nsUnescape(NS_CONST_CAST(char*, m_toPart.get()));
if (!m_ccPart.IsEmpty())
nsUnescape(m_ccPart);
nsUnescape(NS_CONST_CAST(char*, m_ccPart.get()));
if (!m_subjectPart.IsEmpty())
nsUnescape(m_subjectPart);
nsUnescape(NS_CONST_CAST(char*, m_subjectPart.get()));
if (!m_newsgroupPart.IsEmpty())
nsUnescape(m_newsgroupPart);
nsUnescape(NS_CONST_CAST(char*, m_newsgroupPart.get()));
if (!m_referencePart.IsEmpty())
nsUnescape(m_referencePart);
nsUnescape(NS_CONST_CAST(char*, m_referencePart.get()));
if (!m_attachmentPart.IsEmpty())
nsUnescape(m_attachmentPart);
nsUnescape(NS_CONST_CAST(char*, m_attachmentPart.get()));
if (!m_bodyPart.IsEmpty())
nsUnescape(m_bodyPart);
nsUnescape(NS_CONST_CAST(char*, m_bodyPart.get()));
if (!m_newsHostPart.IsEmpty())
nsUnescape(m_newsHostPart);
nsUnescape(NS_CONST_CAST(char*, m_newsHostPart.get()));
return NS_OK;
}
@ -233,7 +233,7 @@ nsresult nsMailtoUrl::ParseUrl()
PRUint32 numExtraChars = m_toPart.Mid(searchPart, startOfSearchPart, -1);
if (!searchPart.IsEmpty())
{
ParseMailtoUrl(searchPart);
ParseMailtoUrl(NS_CONST_CAST(char*, searchPart.get()));
// now we need to strip off the search part from the
// to part....
m_toPart.Cut(startOfSearchPart, numExtraChars);
@ -241,7 +241,7 @@ nsresult nsMailtoUrl::ParseUrl()
}
else if (!m_toPart.IsEmpty())
{
nsUnescape(m_toPart);
nsUnescape(NS_CONST_CAST(char*, m_toPart.get()));
}
return rv;
@ -453,8 +453,8 @@ nsSmtpUrl::SetRecipients(const char * aRecipientsList)
NS_ENSURE_ARG(aRecipientsList);
m_toPart = aRecipientsList;
if (!m_toPart.IsEmpty())
nsUnescape(m_toPart);
return NS_OK;
nsUnescape(NS_CONST_CAST(char*, m_toPart.get()));
return NS_OK;
}

Просмотреть файл

@ -2878,8 +2878,8 @@ NS_IMETHODIMP nsImapService::NewURI(const char *aSpec, nsIURI *aBaseURI, nsIURI
// now extract lots of fun information...
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(aImapUrl);
nsCAutoString unescapedSpec(aSpec);
nsUnescape(unescapedSpec);
mailnewsUrl->SetSpec((char *) unescapedSpec); // set the url spec...
nsUnescape(NS_CONST_CAST(char*, unescapedSpec.get()));
mailnewsUrl->SetSpec(unescapedSpec.get()); // set the url spec...
nsXPIDLCString userName;
nsXPIDLCString hostName;

Просмотреть файл

@ -1201,7 +1201,7 @@ nsPop3Protocol::GurlResponse()
/// the xpidl file which is preventing SetMailAccountURL from taking
// const char *. When that is fixed, we can remove this cast.
if (m_nsIPop3Sink)
m_nsIPop3Sink->SetMailAccountURL((char *) m_commandResponse);
m_nsIPop3Sink->SetMailAccountURL(m_commandResponse.get());
}
else {
m_pop3ConData->capability_flags &= ~POP3_HAS_GURL;

Просмотреть файл

@ -257,7 +257,7 @@ nsPop3Sink::IncorporateBegin(const char* uidlString,
nsCAutoString uidlCString("X-UIDL: ");
uidlCString += uidlString;
uidlCString += MSG_LINEBREAK;
WriteLineToMailbox(uidlCString);
WriteLineToMailbox(NS_CONST_CAST(char*, uidlCString.get()));
}
// WriteLineToMailbox("X-Mozilla-Status: 8000" MSG_LINEBREAK);
char *statusLine = PR_smprintf(X_MOZILLA_STATUS_FORMAT MSG_LINEBREAK, flags);

Просмотреть файл

@ -1720,7 +1720,7 @@ mime_decompose_file_init_fn ( void *stream_closure, MimeHeaders *headers )
newAttachName.Append(".tmp");
}
tmpSpec = nsMsgCreateTempFileSpec(newAttachName);
tmpSpec = nsMsgCreateTempFileSpec(NS_CONST_CAST(char*, newAttachName.get()));
}
// This needs to be done so the attachment structure has a handle

Просмотреть файл

@ -178,7 +178,7 @@ MimeInlineTextPlainFlowed_parse_begin (MimeObject *obj)
openingDiv += '"';
}
openingDiv += ">";
status = MimeObject_write(obj, openingDiv, openingDiv.Length(), PR_FALSE);
status = MimeObject_write(obj, NS_CONST_CAST(char*, openingDiv.get()), openingDiv.Length(), PR_FALSE);
if (status < 0) return status;
}

Просмотреть файл

@ -214,7 +214,7 @@ MimeInlineTextPlain_parse_begin (MimeObject *obj)
}
else
openingDiv = "<pre wrap>";
status = MimeObject_write(obj, openingDiv,openingDiv.Length(), PR_FALSE);
status = MimeObject_write(obj, NS_CONST_CAST(char*, openingDiv.get()), openingDiv.Length(), PR_FALSE);
if (status < 0) return status;
/* text/plain objects always have separators before and after them.

Просмотреть файл

@ -707,7 +707,7 @@ nsresult nsHTTPResponse::EmitHeaders(nsCString& aResponseBuffer)
char *statusLine;
statusLine = PR_smprintf("HTTP/%s %3d %s", versionString, mStatus,
(char*)mStatusString);
mStatusString.get());
if (!statusLine)
return NS_ERROR_OUT_OF_MEMORY;

Просмотреть файл

@ -503,7 +503,8 @@ nsHTTPServerListener::OnDataAvailable(nsIRequest *request,
nsCString ts(trailerHeader);
ts.StripWhitespace();
char *cp = ts;
// XXXjag convert to new string code sometime
char *cp = NS_CONST_CAST(char*, ts.get());
while (*cp) {
char * pp = PL_strchr(cp , ',');

Просмотреть файл

@ -157,7 +157,7 @@ nsIndexedToHTML::Handle201(char* buffer, nsString &pushBuffer)
pushBuffer.AppendWithConversion(filename);
pushBuffer.AppendWithConversion("\"> ");
nsUnescape(filename);
nsUnescape(NS_CONST_CAST(char*, filename.get()));
pushBuffer.AppendWithConversion(filename);
pushBuffer.AppendWithConversion("</a>");
pushBuffer.AppendWithConversion("</td>\n");

Просмотреть файл

@ -82,7 +82,7 @@ int writeDBM(int cycles)
nsCAutoString keyName("foo");
keyName.AppendInt( x );
db_key.data = (char*)keyName;
db_key.data = NS_CONST_CAST(char*, keyName.get());
db_key.size = keyName.Length();
db_data.data = data;
@ -95,7 +95,7 @@ int writeDBM(int cycles)
#if USE_ENTRY_ID
db_key.data = (void*)&x;
db_key.size = sizeof(x);
db_data.data = (char*)keyName;
db_data.data = NS_CONST_CAST(char*, keyName.get());
db_data.size = keyName.Length();
if(0 != (*myDB->put)(myDB, &db_key, &db_data, 0)) {
@ -203,7 +203,7 @@ writeFile(int cycles)
fd = PR_OpenFile(filename, PR_WRONLY|PR_TRUNCATE, 0644);
if (!fd)
printf("bad filename? %s\n", (char*)filename);
printf("bad filename? %s\n", filename.get());
i2 = PR_IntervalNow();

Просмотреть файл

@ -566,7 +566,7 @@ PRUnichar* nsCString::ToNewUnicode() const {
if (result) {
CBufDescriptor desc(result, PR_TRUE, mLength + 1, 0);
nsAutoString temp(desc);
temp.AssignWithConversion(*this);
temp.AssignWithConversion(mStr);
}
return result;
}
@ -589,7 +589,7 @@ char* nsCString::ToCString(char* aBuf, PRUint32 aBufLength,PRUint32 anOffset) co
CBufDescriptor theDescr(aBuf,PR_TRUE,aBufLength,0);
nsCAutoString temp(theDescr);
temp.Assign(*this, PR_MIN(mLength, aBufLength-1));
temp.Assign(mStr, PR_MIN(mLength, aBufLength-1));
temp.mStr=0;
}
return aBuf;

Просмотреть файл

@ -232,7 +232,6 @@ public:
string conversion methods...
*********************************************************************/
//#ifndef STANDALONE_STRING_TESTS
operator char*() {return mStr;}
operator const char*() const {return (const char*)mStr;}
//#endif
@ -528,24 +527,13 @@ class NS_COM NS_ConvertUCS2toUTF8
explicit NS_ConvertUCS2toUTF8( const nsAReadableString& aString );
operator const char*() const // use |get()|
{
NS_WARNING("Implicit conversion from |NS_ConvertUCS2toUTF8| to |const char*| is deprecated, use |get()| instead.");
return get();
}
operator char*() // use |get()|
{
NS_WARNING("Implicit conversion from |NS_ConvertUCS2toUTF8| to |char*| is deprecated, use |NS_CONST_CAST()| and |get()| instead.");
return NS_CONST_CAST(char*, get());
}
protected:
void Append( const PRUnichar* aString, PRUint32 aLength );
private:
// NOT TO BE IMPLEMENTED
NS_ConvertUCS2toUTF8( char );
operator const char*() const; // use |get()|
};

Просмотреть файл

@ -855,7 +855,7 @@ void nsClipboard::SelectionGetCB(GtkWidget *widget,
{
dataFlavor = kUnicodeMime;
} else {
dataFlavor = type;
dataFlavor = type.get();
}
// Get data out of transferable.

Просмотреть файл

@ -1126,7 +1126,7 @@ nsLocalFile::Spawn(const char **args, PRUint32 count)
my_argv[i+1] = (char *)args[i];
}
// we need to set argv[0] to the program name.
my_argv[0] = mResolvedPath;
my_argv[0] = NS_CONST_CAST(char*, mResolvedPath.get());
// null terminate the array
my_argv[count+1] = NULL;

Просмотреть файл

@ -566,7 +566,7 @@ PRUnichar* nsCString::ToNewUnicode() const {
if (result) {
CBufDescriptor desc(result, PR_TRUE, mLength + 1, 0);
nsAutoString temp(desc);
temp.AssignWithConversion(*this);
temp.AssignWithConversion(mStr);
}
return result;
}
@ -589,7 +589,7 @@ char* nsCString::ToCString(char* aBuf, PRUint32 aBufLength,PRUint32 anOffset) co
CBufDescriptor theDescr(aBuf,PR_TRUE,aBufLength,0);
nsCAutoString temp(theDescr);
temp.Assign(*this, PR_MIN(mLength, aBufLength-1));
temp.Assign(mStr, PR_MIN(mLength, aBufLength-1));
temp.mStr=0;
}
return aBuf;

Просмотреть файл

@ -232,7 +232,6 @@ public:
string conversion methods...
*********************************************************************/
//#ifndef STANDALONE_STRING_TESTS
operator char*() {return mStr;}
operator const char*() const {return (const char*)mStr;}
//#endif
@ -528,24 +527,13 @@ class NS_COM NS_ConvertUCS2toUTF8
explicit NS_ConvertUCS2toUTF8( const nsAReadableString& aString );
operator const char*() const // use |get()|
{
NS_WARNING("Implicit conversion from |NS_ConvertUCS2toUTF8| to |const char*| is deprecated, use |get()| instead.");
return get();
}
operator char*() // use |get()|
{
NS_WARNING("Implicit conversion from |NS_ConvertUCS2toUTF8| to |char*| is deprecated, use |NS_CONST_CAST()| and |get()| instead.");
return NS_CONST_CAST(char*, get());
}
protected:
void Append( const PRUnichar* aString, PRUint32 aLength );
private:
// NOT TO BE IMPLEMENTED
NS_ConvertUCS2toUTF8( char );
operator const char*() const; // use |get()|
};

Просмотреть файл

@ -315,7 +315,7 @@ nsString nsStreamTransfer::SuggestNameFor( nsIChannel *aChannel, char const *sug
// try to overwrite c:\config.sys or something.
nsCOMPtr<nsILocalFile> localFile;
nsCAutoString suggestedFileName(suggestedName);
if ( NS_SUCCEEDED( NS_NewLocalFile( nsUnescape(suggestedFileName), PR_FALSE, getter_AddRefs( localFile ) ) ) ) {
if ( NS_SUCCEEDED( NS_NewLocalFile( nsUnescape(NS_CONST_CAST(char*, suggestedFileName.get())), PR_FALSE, getter_AddRefs( localFile ) ) ) ) {
// We want base part of name only.
nsXPIDLString baseName;
if ( NS_SUCCEEDED( localFile->GetUnicodeLeafName( getter_Copies( baseName ) ) ) ) {

Просмотреть файл

@ -295,9 +295,9 @@ PRInt32 nsInstallFile::Complete()
{
nsXPIDLCString path;
mFinalFile->GetPath(getter_Copies(path));
VR_Install( NS_ConvertUCS2toUTF8(*mVersionRegistryName),
(char*)(const char*)path, // DO NOT CHANGE THIS.
NS_ConvertUCS2toUTF8(*mVersionInfo),
VR_Install( NS_CONST_CAST(char*, NS_ConvertUCS2toUTF8(*mVersionRegistryName).get()),
NS_CONST_CAST(char*, path.get()),
NS_CONST_CAST(char*, NS_ConvertUCS2toUTF8(*mVersionInfo).get()),
PR_FALSE );
}