зеркало из https://github.com/mozilla/pjs.git
Bug #379070 --> remove use of nsCRT for |char *| strings in base, db and extensions.
sr=bienvenu
This commit is contained in:
Родитель
a2d09466f8
Коммит
473b780573
|
@ -185,7 +185,7 @@ const char *
|
|||
nsMsgFilterDelegateFactory::getFilterName(const char *filterTag)
|
||||
{
|
||||
|
||||
if (nsCRT::strncmp(filterTag, MSGFILTER_TAG, MSGFILTER_TAG_LENGTH) != 0)
|
||||
if (strncmp(filterTag, MSGFILTER_TAG, MSGFILTER_TAG_LENGTH) != 0)
|
||||
return nsnull;
|
||||
|
||||
const char *filterNameStr = filterTag + MSGFILTER_TAG_LENGTH;
|
||||
|
|
|
@ -183,36 +183,7 @@ nsMsgSearchAdapter::GetImapCharsetParam(const PRUnichar *destCharset)
|
|||
*/
|
||||
PRUnichar *nsMsgSearchAdapter::EscapeSearchUrl (const PRUnichar *nntpCommand)
|
||||
{
|
||||
return nsCRT::strdup(nntpCommand);
|
||||
#if 0
|
||||
PRUnichar *result = nsnull;
|
||||
// max escaped length is two extra characters for every character in the cmd.
|
||||
PRUnichar *scratchBuf = (PRUnichar*) PR_Malloc(sizeof(PRUnichar) * (3*nsCRT::strlen(nntpCommand) + 1));
|
||||
if (scratchBuf)
|
||||
{
|
||||
PRUnichar *scratchPtr = scratchBuf;
|
||||
while (PR_TRUE)
|
||||
{
|
||||
PRUnichar ch = *nntpCommand++;
|
||||
if (!ch)
|
||||
break;
|
||||
if (ch == '#' || ch == '?' || ch == '@' || ch == '\\')
|
||||
{
|
||||
*scratchPtr++ = '\\';
|
||||
nsTextFormatter::snprintf(scratchPtr, 2,
|
||||
NS_LITERAL_STRING("%2.2X").get(), ch);
|
||||
/* Reviewed 4.51 safe use of sprintf */
|
||||
scratchPtr += 2;
|
||||
}
|
||||
else
|
||||
*scratchPtr++ = ch;
|
||||
}
|
||||
*scratchPtr = '\0';
|
||||
result = nsCRT::strdup (scratchBuf); // realloc down to smaller size
|
||||
nsCRT::free (scratchBuf);
|
||||
}
|
||||
return result;
|
||||
#endif
|
||||
return nsCRT::strdup(nntpCommand);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -225,33 +196,6 @@ PRUnichar *
|
|||
nsMsgSearchAdapter::EscapeImapSearchProtocol(const PRUnichar *imapCommand)
|
||||
{
|
||||
return nsCRT::strdup(imapCommand);
|
||||
#if 0
|
||||
PRUnichar *result = nsnull;
|
||||
// max escaped length is one extra character for every character in the cmd.
|
||||
PRUnichar *scratchBuf =
|
||||
(PRUnichar*) PR_Malloc (sizeof(PRUnichar) * (2*nsCRT::strlen(imapCommand) + 1));
|
||||
if (scratchBuf)
|
||||
{
|
||||
PRUnichar *scratchPtr = scratchBuf;
|
||||
while (1)
|
||||
{
|
||||
PRUnichar ch = *imapCommand++;
|
||||
if (!ch)
|
||||
break;
|
||||
if (ch == (PRUnichar)'\\')
|
||||
{
|
||||
*scratchPtr++ = (PRUnichar)'\\';
|
||||
*scratchPtr++ = (PRUnichar)'\\';
|
||||
}
|
||||
else
|
||||
*scratchPtr++ = ch;
|
||||
}
|
||||
*scratchPtr = 0;
|
||||
result = nsCRT::strdup (scratchBuf); // realloc down to smaller size
|
||||
nsCRT::free (scratchBuf);
|
||||
}
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -264,33 +208,6 @@ PRUnichar *
|
|||
nsMsgSearchAdapter::EscapeQuoteImapSearchProtocol(const PRUnichar *imapCommand)
|
||||
{
|
||||
return nsCRT::strdup(imapCommand);
|
||||
#if 0
|
||||
PRUnichar *result = nsnull;
|
||||
// max escaped length is one extra character for every character in the cmd.
|
||||
PRUnichar *scratchBuf =
|
||||
(PRUnichar*) PR_Malloc (sizeof(PRUnichar) * (2*nsCRT::strlen(imapCommand) + 1));
|
||||
if (scratchBuf)
|
||||
{
|
||||
PRUnichar *scratchPtr = scratchBuf;
|
||||
while (1)
|
||||
{
|
||||
PRUnichar ch = *imapCommand++;
|
||||
if (!ch)
|
||||
break;
|
||||
if (ch == '"')
|
||||
{
|
||||
*scratchPtr++ = '\\';
|
||||
*scratchPtr++ = '"';
|
||||
}
|
||||
else
|
||||
*scratchPtr++ = ch;
|
||||
}
|
||||
*scratchPtr = '\0';
|
||||
result = nsCRT::strdup (scratchBuf); // realloc down to smaller size
|
||||
nsCRT::free (scratchBuf);
|
||||
}
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -619,7 +536,7 @@ nsresult nsMsgSearchAdapter::EncodeImapTerm (nsIMsgSearchTerm *term, PRBool real
|
|||
|
||||
searchTermValue.AppendInt(sizeValue);
|
||||
|
||||
value = nsCRT::strdup(searchTermValue.get());
|
||||
value = ToNewCString(searchTermValue);
|
||||
valueWasAllocated = PR_TRUE;
|
||||
}
|
||||
else
|
||||
|
@ -667,11 +584,11 @@ nsresult nsMsgSearchAdapter::EncodeImapTerm (nsIMsgSearchTerm *term, PRBool real
|
|||
*p++ = ch;
|
||||
}
|
||||
*p = '\0';
|
||||
value = nsCRT::strdup(newValue); // realloc down to smaller size
|
||||
value = strdup(newValue); // realloc down to smaller size
|
||||
}
|
||||
}
|
||||
else
|
||||
value = nsCRT::strdup("");
|
||||
value = strdup("");
|
||||
nsCRT::free(convertedValue);
|
||||
valueWasAllocated = PR_TRUE;
|
||||
|
||||
|
@ -814,7 +731,7 @@ char *nsMsgSearchAdapter::TransformSpacesToStars (const char *spaceString, msg_T
|
|||
|
||||
if (transformType == kOverwrite)
|
||||
{
|
||||
if ((starString = nsCRT::strdup(spaceString)) != nsnull)
|
||||
if ((starString = strdup(spaceString)) != nsnull)
|
||||
{
|
||||
char *star = starString;
|
||||
while ((star = PL_strchr(star, ' ')) != nsnull)
|
||||
|
@ -863,7 +780,7 @@ char *nsMsgSearchAdapter::TransformSpacesToStars (const char *spaceString, msg_T
|
|||
}
|
||||
}
|
||||
else
|
||||
starString = nsCRT::strdup(spaceString);
|
||||
starString = strdup(spaceString);
|
||||
}
|
||||
|
||||
return starString;
|
||||
|
@ -1150,14 +1067,12 @@ nsMsgSearchValidityManager::SetOtherHeadersInTable (nsIMsgSearchValidityTable *a
|
|||
PRUint32 numHeaders=0;
|
||||
if (customHeadersLength)
|
||||
{
|
||||
char *headersString = nsCRT::strdup(customHeaders);
|
||||
|
||||
nsCAutoString hdrStr;
|
||||
hdrStr.Adopt(headersString);
|
||||
hdrStr.StripWhitespace(); //remove whitespace before parsing
|
||||
char *headersString = strdup(customHeaders);
|
||||
|
||||
nsCAutoString hdrStr(customHeaders);
|
||||
hdrStr.StripWhitespace(); //remove whitespace before parsing
|
||||
char *newStr=nsnull;
|
||||
char *token = nsCRT::strtok(headersString,":", &newStr);
|
||||
char *token = nsCRT::strtok(hdrStr.BeginWriting(),":", &newStr);
|
||||
while(token)
|
||||
{
|
||||
numHeaders++;
|
||||
|
|
|
@ -146,18 +146,15 @@ nsresult NS_MsgGetAttributeFromString(const char *string, PRInt16 *attrib)
|
|||
|
||||
if (!headers.IsEmpty())
|
||||
{
|
||||
char *headersString = ToNewCString(headers);
|
||||
|
||||
nsCAutoString hdrStr;
|
||||
hdrStr.Adopt(headersString);
|
||||
nsCAutoString hdrStr(headers);
|
||||
hdrStr.StripWhitespace(); //remove whitespace before parsing
|
||||
|
||||
char *newStr=nsnull;
|
||||
char *token = nsCRT::strtok(headersString,":", &newStr);
|
||||
char *token = nsCRT::strtok(hdrStr.BeginWriting(), ":", &newStr);
|
||||
PRUint32 i=0;
|
||||
while (token)
|
||||
{
|
||||
if (nsCRT::strcasecmp(token, string) == 0)
|
||||
if (PL_strcasecmp(token, string) == 0)
|
||||
{
|
||||
*attrib += i; //we found custom header in the pref
|
||||
found = PR_TRUE;
|
||||
|
|
|
@ -52,9 +52,8 @@ nsMsgSearchValueImpl::nsMsgSearchValueImpl(nsMsgSearchValue *aInitialValue)
|
|||
|
||||
nsMsgSearchValueImpl::~nsMsgSearchValueImpl()
|
||||
{
|
||||
if (IS_STRING_ATTRIBUTE(mValue.attribute))
|
||||
nsCRT::free(mValue.string);
|
||||
|
||||
if (IS_STRING_ATTRIBUTE(mValue.attribute))
|
||||
NS_Free(mValue.string);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsMsgSearchValueImpl, nsIMsgSearchValue)
|
||||
|
@ -72,19 +71,19 @@ NS_IMPL_GETSET(nsMsgSearchValueImpl, JunkStatus, PRUint32, mValue.u.junkStatus)
|
|||
NS_IMETHODIMP
|
||||
nsMsgSearchValueImpl::GetFolder(nsIMsgFolder* *aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
NS_ENSURE_TRUE(mValue.attribute == nsMsgSearchAttrib::FolderInfo, NS_ERROR_ILLEGAL_VALUE);
|
||||
*aResult = mValue.u.folder;
|
||||
NS_IF_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
NS_ENSURE_TRUE(mValue.attribute == nsMsgSearchAttrib::FolderInfo, NS_ERROR_ILLEGAL_VALUE);
|
||||
*aResult = mValue.u.folder;
|
||||
NS_IF_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgSearchValueImpl::SetFolder(nsIMsgFolder* aValue)
|
||||
{
|
||||
NS_ENSURE_TRUE(mValue.attribute == nsMsgSearchAttrib::FolderInfo, NS_ERROR_ILLEGAL_VALUE);
|
||||
mValue.u.folder = aValue;
|
||||
return NS_OK;
|
||||
NS_ENSURE_TRUE(mValue.attribute == nsMsgSearchAttrib::FolderInfo, NS_ERROR_ILLEGAL_VALUE);
|
||||
mValue.u.folder = aValue;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -100,7 +99,7 @@ nsMsgSearchValueImpl::SetStr(const nsAString &aValue)
|
|||
{
|
||||
NS_ENSURE_TRUE(IS_STRING_ATTRIBUTE(mValue.attribute), NS_ERROR_ILLEGAL_VALUE);
|
||||
if (mValue.string)
|
||||
nsCRT::free(mValue.string);
|
||||
NS_Free(mValue.string);
|
||||
mValue.string = ToNewUTF8String(aValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -66,7 +66,7 @@ NS_IMETHODIMP nsMessengerContentHandler::HandleContent(const char * aContentType
|
|||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// First of all, get the content type and make sure it is a content type we know how to handle!
|
||||
if (nsCRT::strcasecmp(aContentType, "application/x-message-display") == 0) {
|
||||
if (PL_strcasecmp(aContentType, "application/x-message-display") == 0) {
|
||||
nsCOMPtr<nsIURI> aUri;
|
||||
nsCOMPtr<nsIChannel> aChannel = do_QueryInterface(request);
|
||||
if (!aChannel) return NS_ERROR_FAILURE;
|
||||
|
|
|
@ -213,8 +213,7 @@ nsMsgAccount::createIdentities()
|
|||
// const-casting because nsCRT::strtok whacks the string,
|
||||
// but safe because identityKey is a copy
|
||||
char* newStr;
|
||||
char* rest = identityKey.BeginWriting();
|
||||
char* token = nsCRT::strtok(rest, ",", &newStr);
|
||||
char* token = nsCRT::strtok(identityKey.BeginWriting(), ",", &newStr);
|
||||
|
||||
// temporaries used inside the loop
|
||||
nsCOMPtr<nsIMsgIdentity> identity;
|
||||
|
@ -316,8 +315,7 @@ nsMsgAccount::AddIdentity(nsIMsgIdentity *identity)
|
|||
// const-casting because nsCRT::strtok whacks the string,
|
||||
// but safe because identityList is a copy
|
||||
char *newStr;
|
||||
char *rest = identityList.BeginWriting();
|
||||
char *token = nsCRT::strtok(rest, ",", &newStr);
|
||||
char *token = nsCRT::strtok(identityList.BeginWriting(), ",", &newStr);
|
||||
|
||||
// look for the identity key that we're adding
|
||||
while (token) {
|
||||
|
|
|
@ -267,19 +267,19 @@ nsMsgAccountManager::SetUserNeedsToAuthenticate(PRBool aUserNeedsToAuthenticate)
|
|||
|
||||
NS_IMETHODIMP nsMsgAccountManager::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData)
|
||||
{
|
||||
if(!nsCRT::strcmp(aTopic,NS_XPCOM_SHUTDOWN_OBSERVER_ID))
|
||||
if(!strcmp(aTopic,NS_XPCOM_SHUTDOWN_OBSERVER_ID))
|
||||
{
|
||||
Shutdown();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!nsCRT::strcmp(aTopic,"quit-application"))
|
||||
if (!strcmp(aTopic,"quit-application"))
|
||||
{
|
||||
m_shutdownInProgress = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!nsCRT::strcmp(aTopic, ABOUT_TO_GO_OFFLINE_TOPIC))
|
||||
if (!strcmp(aTopic, ABOUT_TO_GO_OFFLINE_TOPIC))
|
||||
{
|
||||
nsAutoString dataString(NS_LITERAL_STRING("offline"));
|
||||
if (someData)
|
||||
|
@ -291,13 +291,13 @@ NS_IMETHODIMP nsMsgAccountManager::Observe(nsISupports *aSubject, const char *aT
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!nsCRT::strcmp(aTopic, "session-logout"))
|
||||
if (!strcmp(aTopic, "session-logout"))
|
||||
{
|
||||
m_incomingServers.Enumerate(hashLogoutOfServer, nsnull);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!nsCRT::strcmp(aTopic, "profile-before-change"))
|
||||
if (!strcmp(aTopic, "profile-before-change"))
|
||||
{
|
||||
Shutdown();
|
||||
return NS_OK;
|
||||
|
@ -671,9 +671,7 @@ nsMsgAccountManager::removeKeyedAccount(const nsCString& key)
|
|||
// the one with 'key'
|
||||
nsCAutoString newAccountList;
|
||||
char *newStr;
|
||||
char *rest = accountList.BeginWriting();
|
||||
|
||||
char *token = nsCRT::strtok(rest, ",", &newStr);
|
||||
char *token = nsCRT::strtok(accountList.BeginWriting(), ",", &newStr);
|
||||
while (token) {
|
||||
nsCAutoString testKey(token);
|
||||
testKey.StripWhitespace();
|
||||
|
@ -1281,8 +1279,7 @@ nsMsgAccountManager::LoadAccounts()
|
|||
// Tokenize the data and add each account if it is not already there
|
||||
// in the user's current mailnews account list
|
||||
char *newAccountStr;
|
||||
char *preConfigAccountsStr = ToNewCString(appendAccountList);
|
||||
char *token = nsCRT::strtok(preConfigAccountsStr, ACCOUNT_DELIMITER, &newAccountStr);
|
||||
char *token = nsCRT::strtok(appendAccountList.BeginWriting(), ACCOUNT_DELIMITER, &newAccountStr);
|
||||
|
||||
nsCAutoString newAccount;
|
||||
while (token) {
|
||||
|
@ -1297,7 +1294,6 @@ nsMsgAccountManager::LoadAccounts()
|
|||
}
|
||||
token = nsCRT::strtok(newAccountStr, ACCOUNT_DELIMITER, &newAccountStr);
|
||||
}
|
||||
PR_Free(preConfigAccountsStr);
|
||||
}
|
||||
else {
|
||||
accountList = appendAccountList;
|
||||
|
@ -1320,8 +1316,8 @@ nsMsgAccountManager::LoadAccounts()
|
|||
char *rest = accountList.BeginWriting();
|
||||
nsCAutoString str;
|
||||
for (char *token = nsCRT::strtok(rest, ",", &newStr);
|
||||
token;
|
||||
token = nsCRT::strtok(newStr, ",", &newStr))
|
||||
token;
|
||||
token = nsCRT::strtok(newStr, ",", &newStr))
|
||||
{
|
||||
str = token;
|
||||
str.StripWhitespace();
|
||||
|
|
|
@ -239,11 +239,8 @@ NS_IMETHODIMP nsMsgBiffManager::OnServerChanged(nsIMsgIncomingServer *server)
|
|||
|
||||
NS_IMETHODIMP nsMsgBiffManager::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData)
|
||||
{
|
||||
if(!nsCRT::strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID))
|
||||
{
|
||||
if(!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID))
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -583,7 +583,7 @@ nsMsgContentPolicy::ShouldProcess(PRUint32 aContentType,
|
|||
|
||||
NS_IMETHODIMP nsMsgContentPolicy::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData)
|
||||
{
|
||||
if (!nsCRT::strcmp(NS_PREFBRANCH_PREFCHANGE_TOPIC_ID, aTopic))
|
||||
if (!strcmp(NS_PREFBRANCH_PREFCHANGE_TOPIC_ID, aTopic))
|
||||
{
|
||||
NS_LossyConvertUTF16toASCII pref(aData);
|
||||
|
||||
|
|
|
@ -406,7 +406,7 @@ nsMsgFolderDataSource::QueryInterface(REFNSIID iid, void** result)
|
|||
// nsIRDFDataSource methods
|
||||
NS_IMETHODIMP nsMsgFolderDataSource::GetURI(char* *uri)
|
||||
{
|
||||
if ((*uri = nsCRT::strdup("rdf:mailnewsfolders")) == nsnull)
|
||||
if ((*uri = strdup("rdf:mailnewsfolders")) == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
else
|
||||
return NS_OK;
|
||||
|
|
|
@ -119,9 +119,9 @@ nsMsgPrintEngine::OnStateChange(nsIWebProgress* aWebProgress,
|
|||
if (progressStateFlags & nsIWebProgressListener::STATE_IS_DOCUMENT) {
|
||||
if (progressStateFlags & nsIWebProgressListener::STATE_START) {
|
||||
// Tell the user we are loading...
|
||||
PRUnichar *msg = GetString(NS_LITERAL_STRING("LoadingMessageToPrint").get());
|
||||
SetStatusMessage( msg );
|
||||
CRTFREEIF(msg)
|
||||
nsString msg;
|
||||
GetString(NS_LITERAL_STRING("LoadingMessageToPrint").get(), msg);
|
||||
SetStatusMessage(msg);
|
||||
}
|
||||
|
||||
if (progressStateFlags & nsIWebProgressListener::STATE_STOP) {
|
||||
|
@ -162,9 +162,9 @@ nsMsgPrintEngine::OnStateChange(nsIWebProgress* aWebProgress,
|
|||
rv = NS_ERROR_FAILURE;
|
||||
|
||||
// Tell the user the message is loaded...
|
||||
PRUnichar *msg = GetString(NS_LITERAL_STRING("MessageLoaded").get());
|
||||
SetStatusMessage( msg );
|
||||
if (msg) nsCRT::free(msg);
|
||||
nsString msg;
|
||||
GetString(NS_LITERAL_STRING("MessageLoaded").get(), msg);
|
||||
SetStatusMessage(msg);
|
||||
|
||||
NS_ASSERTION(mDocShell,"can't print, there is no docshell");
|
||||
if ( (!mDocShell) || (!aRequest) )
|
||||
|
@ -416,17 +416,14 @@ nsMsgPrintEngine::ShowProgressDialog(PRBool aIsForPrinting, PRBool& aDoNotify)
|
|||
nsIWebProgressListener* wpl = NS_STATIC_CAST(nsIWebProgressListener*, mPrintProgressListener.get());
|
||||
NS_ASSERTION(wpl, "nsIWebProgressListener is NULL!");
|
||||
NS_ADDREF(wpl);
|
||||
PRUnichar *msg = nsnull;
|
||||
nsString msg;
|
||||
if (mIsDoingPrintPreview) {
|
||||
GetString(NS_LITERAL_STRING("LoadingMailMsgForPrintPreview").get());
|
||||
GetString(NS_LITERAL_STRING("LoadingMailMsgForPrintPreview").get(), msg);
|
||||
} else {
|
||||
GetString(NS_LITERAL_STRING("LoadingMailMsgForPrint").get());
|
||||
}
|
||||
if (msg)
|
||||
{
|
||||
mPrintProgressParams->SetDocTitle(msg);
|
||||
nsCRT::free(msg);
|
||||
GetString(NS_LITERAL_STRING("LoadingMailMsgForPrint").get(), msg);
|
||||
}
|
||||
if (!msg.IsEmpty())
|
||||
mPrintProgressParams->SetDocTitle(msg.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -453,10 +450,9 @@ nsMsgPrintEngine::StartNextPrintOperation()
|
|||
mWindow->Close();
|
||||
|
||||
// Tell the user we are done...
|
||||
PRUnichar *msg = GetString(NS_LITERAL_STRING("PrintingComplete").get());
|
||||
SetStatusMessage( msg );
|
||||
CRTFREEIF(msg)
|
||||
|
||||
nsString msg;
|
||||
GetString(NS_LITERAL_STRING("PrintingComplete").get(), msg);
|
||||
SetStatusMessage(msg);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -464,7 +460,7 @@ nsMsgPrintEngine::StartNextPrintOperation()
|
|||
return StartNextPrintOperation();
|
||||
|
||||
nsString *uri = mURIArray.StringAt(mCurrentlyPrintingURI);
|
||||
rv = FireThatLoadOperationStartup(uri);
|
||||
rv = FireThatLoadOperationStartup(*uri);
|
||||
if (NS_FAILED(rv))
|
||||
return StartNextPrintOperation();
|
||||
else
|
||||
|
@ -479,49 +475,36 @@ nsMsgPrintEngine::SetStatusFeedback(nsIMsgStatusFeedback *aFeedback)
|
|||
}
|
||||
|
||||
#define DATA_URL_PREFIX "data:"
|
||||
#define DATA_URL_PREFIX_LEN 5
|
||||
|
||||
#define ADDBOOK_URL_PREFIX "addbook:"
|
||||
#define ADDBOOK_URL_PREFIX_LEN 8
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgPrintEngine::FireThatLoadOperationStartup(nsString *uri)
|
||||
nsresult
|
||||
nsMsgPrintEngine::FireThatLoadOperationStartup(const nsString& uri)
|
||||
{
|
||||
if (uri)
|
||||
{
|
||||
mLoadURI = *uri;
|
||||
}
|
||||
else
|
||||
{
|
||||
mLoadURI.SetLength(0);
|
||||
}
|
||||
if (!uri.IsEmpty())
|
||||
mLoadURI = uri;
|
||||
else
|
||||
mLoadURI.Truncate();
|
||||
|
||||
PRBool notify = PR_FALSE;
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
// Don't show dialog if we are out of URLs
|
||||
//if ( mCurrentlyPrintingURI < mURIArray.Count() && !mIsDoingPrintPreview)
|
||||
if ( mCurrentlyPrintingURI < mURIArray.Count())
|
||||
{
|
||||
rv = ShowProgressDialog(!mIsDoingPrintPreview, notify);
|
||||
}
|
||||
if (NS_FAILED(rv) || !notify)
|
||||
{
|
||||
return FireThatLoadOperation(uri);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgPrintEngine::FireThatLoadOperation(nsString *uri)
|
||||
nsresult
|
||||
nsMsgPrintEngine::FireThatLoadOperation(const nsString& uri)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
char *tString = ToNewCString(*uri);
|
||||
if (!tString)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
nsresult rv;
|
||||
|
||||
nsCString uriCStr;
|
||||
LossyCopyUTF16toASCII(uri, uriCStr);
|
||||
|
||||
nsCOMPtr <nsIMsgMessageService> messageService;
|
||||
|
||||
// if this is a data: url, skip it, because
|
||||
// we've already got something we can print
|
||||
// and we know it is not a message.
|
||||
|
@ -536,30 +519,26 @@ nsMsgPrintEngine::FireThatLoadOperation(nsString *uri)
|
|||
// skip it, because we don't want to print the parent message
|
||||
// we want to print the part.
|
||||
// example: imap://sspitzer@nsmail-1:143/fetch%3EUID%3E/INBOX%3E180958?part=1.1.2&type=application/x-message-display&filename=test"
|
||||
if (strncmp(tString, DATA_URL_PREFIX, DATA_URL_PREFIX_LEN) &&
|
||||
strncmp(tString, ADDBOOK_URL_PREFIX, ADDBOOK_URL_PREFIX_LEN) &&
|
||||
strcmp(tString, "about:blank") &&
|
||||
!strstr(tString, "type=application/x-message-display")) {
|
||||
rv = GetMessageServiceFromURI(tString, getter_AddRefs(messageService));
|
||||
if (!StringBeginsWith(uriCStr, NS_LITERAL_CSTRING(DATA_URL_PREFIX)) &&
|
||||
!StringBeginsWith(uriCStr, NS_LITERAL_CSTRING(ADDBOOK_URL_PREFIX)) &&
|
||||
!uriCStr.EqualsLiteral("about:blank") &&
|
||||
uriCStr.Find(NS_LITERAL_CSTRING("type=application/x-message-display")) == -1) {
|
||||
rv = GetMessageServiceFromURI(uriCStr.get(), getter_AddRefs(messageService));
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv) && messageService)
|
||||
{
|
||||
rv = messageService->DisplayMessageForPrinting(tString, mDocShell, nsnull, nsnull, nsnull);
|
||||
}
|
||||
rv = messageService->DisplayMessageForPrinting(uriCStr.get(), mDocShell, nsnull, nsnull, nsnull);
|
||||
//If it's not something we know about, then just load try loading it directly.
|
||||
else
|
||||
{
|
||||
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
|
||||
if (webNav)
|
||||
rv = webNav->LoadURI(uri->get(), // URI string
|
||||
rv = webNav->LoadURI(uri.get(), // URI string
|
||||
nsIWebNavigation::LOAD_FLAGS_NONE, // Load flags
|
||||
nsnull, // Referring URI
|
||||
nsnull, // Post data
|
||||
nsnull); // Extra headers
|
||||
}
|
||||
|
||||
if (tString) nsCRT::free(tString);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -606,42 +585,36 @@ nsMsgPrintEngine::SetupObserver()
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsMsgPrintEngine::SetStatusMessage(PRUnichar *aMsgString)
|
||||
nsMsgPrintEngine::SetStatusMessage(const nsString& aMsgString)
|
||||
{
|
||||
if ( (!mFeedback) || (!aMsgString) )
|
||||
if ( (!mFeedback) || (aMsgString.IsEmpty()) )
|
||||
return NS_OK;
|
||||
|
||||
mFeedback->ShowStatusString(aMsgString);
|
||||
mFeedback->ShowStatusString(aMsgString.get());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#define MESSENGER_STRING_URL "chrome://messenger/locale/messenger.properties"
|
||||
|
||||
PRUnichar *
|
||||
nsMsgPrintEngine::GetString(const PRUnichar *aStringName)
|
||||
void
|
||||
nsMsgPrintEngine::GetString(const PRUnichar *aStringName, nsString& outStr)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
PRUnichar *ptrv = nsnull;
|
||||
nsresult res = NS_OK;
|
||||
outStr.Truncate();
|
||||
|
||||
if (!mStringBundle)
|
||||
{
|
||||
static const char propertyURL[] = MESSENGER_STRING_URL;
|
||||
if (!mStringBundle)
|
||||
{
|
||||
static const char propertyURL[] = MESSENGER_STRING_URL;
|
||||
|
||||
nsCOMPtr<nsIStringBundleService> sBundleService =
|
||||
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &res);
|
||||
if (NS_SUCCEEDED(res) && (nsnull != sBundleService))
|
||||
{
|
||||
res = sBundleService->CreateBundle(propertyURL, getter_AddRefs(mStringBundle));
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIStringBundleService> sBundleService =
|
||||
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &res);
|
||||
if (NS_SUCCEEDED(res) && (nsnull != sBundleService))
|
||||
res = sBundleService->CreateBundle(propertyURL, getter_AddRefs(mStringBundle));
|
||||
}
|
||||
|
||||
if (mStringBundle)
|
||||
res = mStringBundle->GetStringFromName(aStringName, &ptrv);
|
||||
|
||||
if ( NS_SUCCEEDED(res) && (ptrv) )
|
||||
return ptrv;
|
||||
else
|
||||
return nsCRT::strdup(aStringName);
|
||||
if (mStringBundle)
|
||||
res = mStringBundle->GetStringFromName(aStringName, getter_Copies(outStr));
|
||||
return;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------
|
||||
|
@ -712,9 +685,9 @@ nsMsgPrintEngine::PrintMsgWindow()
|
|||
else
|
||||
{
|
||||
// Tell the user we started printing...
|
||||
PRUnichar *msg = GetString(NS_ConvertASCIItoUTF16(kMsgKeys[mMsgInx]).get());
|
||||
SetStatusMessage( msg );
|
||||
CRTFREEIF(msg)
|
||||
nsString msg;
|
||||
GetString(NS_ConvertASCIItoUTF16(kMsgKeys[mMsgInx]).get(), msg);
|
||||
SetStatusMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -829,5 +802,5 @@ NS_IMETHODIMP nsMsgPrintEngine::SetMsgType(PRInt32 aMsgType)
|
|||
/*=============== nsIObserver Interface ======================*/
|
||||
NS_IMETHODIMP nsMsgPrintEngine::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData)
|
||||
{
|
||||
return FireThatLoadOperation(&mLoadURI);
|
||||
return FireThatLoadOperation(mLoadURI);
|
||||
}
|
||||
|
|
|
@ -89,12 +89,12 @@ protected:
|
|||
|
||||
PRBool FirePrintEvent();
|
||||
PRBool FireStartNextEvent();
|
||||
NS_IMETHOD FireThatLoadOperationStartup(nsString *uri);
|
||||
NS_IMETHOD FireThatLoadOperation(nsString *uri);
|
||||
nsresult FireThatLoadOperationStartup(const nsString& uri);
|
||||
nsresult FireThatLoadOperation(const nsString& uri);
|
||||
void InitializeDisplayCharset();
|
||||
void SetupObserver();
|
||||
nsresult SetStatusMessage(PRUnichar *aMsgString);
|
||||
PRUnichar *GetString(const PRUnichar *aStringName);
|
||||
nsresult SetStatusMessage(const nsString& aMsgString);
|
||||
void GetString(const PRUnichar *aStringName, nsString& aOutString);
|
||||
nsresult ShowProgressDialog(PRBool aIsForPrinting, PRBool& aDoNotify);
|
||||
|
||||
nsCOMPtr<nsIDocShell> mDocShell;
|
||||
|
@ -120,5 +120,5 @@ protected:
|
|||
nsCOMPtr<nsIWebProgressListener> mPrintProgressListener;
|
||||
nsCOMPtr<nsIPrintProgress> mPrintProgress;
|
||||
nsCOMPtr<nsIPrintProgressParams> mPrintProgressParams;
|
||||
nsAutoString mLoadURI;
|
||||
nsString mLoadURI;
|
||||
};
|
||||
|
|
|
@ -105,7 +105,7 @@ nsSoundDatasource::Init()
|
|||
NS_IMETHODIMP
|
||||
nsSoundDatasource::GetURI(char **aURI)
|
||||
{
|
||||
if ((*aURI = nsCRT::strdup("rdf:mailsounds")) == nsnull)
|
||||
if ((*aURI = strdup("rdf:mailsounds")) == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
else
|
||||
return NS_OK;
|
||||
|
|
|
@ -484,7 +484,7 @@ nsSubscribableServer::CreateNode(SubscribeTreeNode *parent, const char *name, Su
|
|||
*result = (SubscribeTreeNode *) PR_Malloc(sizeof(SubscribeTreeNode));
|
||||
if (!*result) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
(*result)->name = nsCRT::strdup(name);
|
||||
(*result)->name = strdup(name);
|
||||
if (!(*result)->name) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
(*result)->parent = parent;
|
||||
|
@ -531,7 +531,7 @@ nsSubscribableServer::AddChildNode(SubscribeTreeNode *parent, const char *name,
|
|||
}
|
||||
else {
|
||||
if (parent->cachedChild) {
|
||||
if (nsCRT::strcmp(parent->cachedChild->name,name) == 0) {
|
||||
if (strcmp(parent->cachedChild->name,name) == 0) {
|
||||
*child = parent->cachedChild;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -552,7 +552,7 @@ nsSubscribableServer::AddChildNode(SubscribeTreeNode *parent, const char *name,
|
|||
* we can efficiently reverse the order when dumping to hostinfo.dat
|
||||
* or to GetTargets()
|
||||
*/
|
||||
PRInt32 compare = nsCRT::strcmp(current->name, name);
|
||||
PRInt32 compare = strcmp(current->name, name);
|
||||
|
||||
while (current && (compare != 0)) {
|
||||
if (compare < 0) {
|
||||
|
@ -577,7 +577,7 @@ nsSubscribableServer::AddChildNode(SubscribeTreeNode *parent, const char *name,
|
|||
current = current->nextSibling;
|
||||
if (current) {
|
||||
NS_ASSERTION(current->name, "no name!");
|
||||
compare = nsCRT::strcmp(current->name,name);
|
||||
compare = strcmp(current->name,name);
|
||||
}
|
||||
else {
|
||||
compare = -1; // anything but 0, since that would be a match
|
||||
|
|
|
@ -117,7 +117,7 @@ nsSubscribeDataSource::Init()
|
|||
NS_IMETHODIMP
|
||||
nsSubscribeDataSource::GetURI(char * *aURI)
|
||||
{
|
||||
if ((*aURI = nsCRT::strdup("rdf:subscribe")) == nsnull)
|
||||
if ((*aURI = strdup("rdf:subscribe")) == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
else
|
||||
return NS_OK;
|
||||
|
@ -445,7 +445,7 @@ nsSubscribeDataSource::GetServerAndRelativePathFromResource(nsIRDFResource *sour
|
|||
*relativePath = nsnull;
|
||||
else {
|
||||
// XXX : perhaps, have to unescape before returning
|
||||
*relativePath = nsCRT::strdup(sourceURI + serverURILen + 1);
|
||||
*relativePath = strdup(sourceURI + serverURILen + 1);
|
||||
if (!*relativePath)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
|
@ -257,7 +257,7 @@ char * nsMsgI18NEncodeMimePartIIStr(const char *header, PRBool structured, const
|
|||
PRBool nsMsgI18Nstateful_charset(const char *charset)
|
||||
{
|
||||
//TODO: use charset manager's service
|
||||
return (nsCRT::strcasecmp(charset, "ISO-2022-JP") == 0);
|
||||
return (PL_strcasecmp(charset, "ISO-2022-JP") == 0);
|
||||
}
|
||||
|
||||
PRBool nsMsgI18Nmultibyte_charset(const char *charset)
|
||||
|
@ -382,8 +382,8 @@ nsMsgI18NParseMetaCharset(nsILocalFile* file)
|
|||
// so we can say that the charset label must be incorrect for
|
||||
// the .html if we actually see those charsets parsed
|
||||
// and we should ignore them
|
||||
if (!nsCRT::strncasecmp("UTF-16", charset, sizeof("UTF-16")-1) ||
|
||||
!nsCRT::strncasecmp("UTF-32", charset, sizeof("UTF-32")-1))
|
||||
if (!PL_strncasecmp("UTF-16", charset, sizeof("UTF-16")-1) ||
|
||||
!PL_strncasecmp("UTF-32", charset, sizeof("UTF-32")-1))
|
||||
charset[0] = '\0';
|
||||
|
||||
break;
|
||||
|
@ -424,7 +424,7 @@ nsresult nsMsgI18NSaveAsCharset(const char* contentType, const char *charset,
|
|||
if (nsCRT::IsAscii(inString)) {
|
||||
if (isAsciiOnly)
|
||||
*isAsciiOnly = PR_TRUE;
|
||||
*outString = nsCRT::strdup(NS_LossyConvertUTF16toASCII(inString).get());
|
||||
*outString = ToNewCString(NS_LossyConvertUTF16toASCII(inString));
|
||||
return (nsnull != *outString) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
if (isAsciiOnly)
|
||||
|
@ -433,10 +433,10 @@ nsresult nsMsgI18NSaveAsCharset(const char* contentType, const char *charset,
|
|||
PRBool bTEXT_HTML = PR_FALSE;
|
||||
nsresult res;
|
||||
|
||||
if (!nsCRT::strcasecmp(contentType, TEXT_HTML)) {
|
||||
if (!PL_strcasecmp(contentType, TEXT_HTML)) {
|
||||
bTEXT_HTML = PR_TRUE;
|
||||
}
|
||||
else if (nsCRT::strcasecmp(contentType, TEXT_PLAIN)) {
|
||||
else if (PL_strcasecmp(contentType, TEXT_PLAIN)) {
|
||||
return NS_ERROR_ILLEGAL_VALUE; // not supported type
|
||||
}
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ NS_IMETHODIMP nsFolderCharsetObserver::Observe(nsISupports *aSubject, const char
|
|||
rv = prefs->GetBranch(nsnull, getter_AddRefs(prefBranch));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!nsCRT::strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID))
|
||||
if (!strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID))
|
||||
{
|
||||
nsDependentString prefName(someData);
|
||||
|
||||
|
@ -134,7 +134,7 @@ NS_IMETHODIMP nsFolderCharsetObserver::Observe(nsISupports *aSubject, const char
|
|||
rv = prefBranch->GetBoolPref(kMAILNEWS_DEFAULT_CHARSET_OVERRIDE, &gDefaultCharacterOverride);
|
||||
}
|
||||
}
|
||||
else if (!nsCRT::strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID))
|
||||
else if (!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID))
|
||||
{
|
||||
nsCOMPtr<nsIPrefBranch2> pbi = do_QueryInterface(prefBranch);
|
||||
if (pbi)
|
||||
|
|
|
@ -1139,17 +1139,13 @@ nsresult nsMsgDatabase::OpenMDB(const char *dbName, PRBool create)
|
|||
{
|
||||
nsIMdbThumb *thumb = nsnull;
|
||||
struct stat st;
|
||||
char *nativeFileName = nsCRT::strdup(dbName);
|
||||
nsIMdbHeap* dbHeap = 0;
|
||||
mdb_bool dbFrozen = mdbBool_kFalse; // not readonly, we want modifiable
|
||||
|
||||
if (!nativeFileName)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (m_mdbEnv)
|
||||
m_mdbEnv->SetAutoClear(PR_TRUE);
|
||||
m_dbName = dbName;
|
||||
if (stat(nativeFileName, &st))
|
||||
if (stat(dbName, &st))
|
||||
ret = NS_MSG_ERROR_FOLDER_SUMMARY_MISSING;
|
||||
else
|
||||
{
|
||||
|
@ -1158,7 +1154,7 @@ nsresult nsMsgDatabase::OpenMDB(const char *dbName, PRBool create)
|
|||
mdbYarn outFormatVersion;
|
||||
|
||||
nsIMdbFile* oldFile = 0;
|
||||
ret = myMDBFactory->OpenOldFile(m_mdbEnv, dbHeap, nativeFileName,
|
||||
ret = myMDBFactory->OpenOldFile(m_mdbEnv, dbHeap, dbName,
|
||||
dbFrozen, &oldFile);
|
||||
if ( oldFile )
|
||||
{
|
||||
|
@ -1234,7 +1230,6 @@ nsresult nsMsgDatabase::OpenMDB(const char *dbName, PRBool create)
|
|||
}
|
||||
}
|
||||
NS_IF_RELEASE(thumb);
|
||||
nsCRT::free(nativeFileName);
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG_David_Bienvenu
|
||||
|
@ -3341,7 +3336,7 @@ nsresult nsMsgDatabase::RowCellColumnToCharPtr(nsIMdbRow *row, mdb_token columnT
|
|||
|
||||
}
|
||||
else if (err == NS_OK) // guarantee a non-null result
|
||||
*result = nsCRT::strdup("");
|
||||
*result = strdup("");
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -415,44 +415,43 @@ NS_IMETHODIMP nsMsgHdr::SetRecipients(const char *recipients)
|
|||
|
||||
nsresult nsMsgHdr::BuildRecipientsFromArray(const char *names, const char *addresses, PRUint32 numAddresses, nsCAutoString& allRecipients)
|
||||
{
|
||||
nsresult ret = NS_OK;
|
||||
const char *curName = names;
|
||||
const char *curAddress = addresses;
|
||||
nsIMsgHeaderParser *headerParser = m_mdb->GetHeaderParser();
|
||||
nsresult ret = NS_OK;
|
||||
const char *curName = names;
|
||||
const char *curAddress = addresses;
|
||||
nsIMsgHeaderParser *headerParser = m_mdb->GetHeaderParser();
|
||||
|
||||
for (PRUint32 i = 0; i < numAddresses; i++, curName += strlen(curName) + 1, curAddress += strlen(curAddress) + 1)
|
||||
{
|
||||
if (i > 0)
|
||||
allRecipients += ", ";
|
||||
for (PRUint32 i = 0; i < numAddresses; i++, curName += strlen(curName) + 1, curAddress += strlen(curAddress) + 1)
|
||||
{
|
||||
if (i > 0)
|
||||
allRecipients += ", ";
|
||||
|
||||
if (headerParser)
|
||||
{
|
||||
char * fullAddress;
|
||||
ret = headerParser->MakeFullAddress(nsnull, curName, curAddress, &fullAddress);
|
||||
if (NS_SUCCEEDED(ret) && fullAddress)
|
||||
{
|
||||
allRecipients += fullAddress;
|
||||
nsCRT::free(fullAddress);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (headerParser)
|
||||
{
|
||||
nsCString fullAddress;
|
||||
ret = headerParser->MakeFullAddress(nsnull, curName, curAddress, getter_Copies(fullAddress));
|
||||
if (NS_SUCCEEDED(ret) && !fullAddress.IsEmpty())
|
||||
{
|
||||
allRecipients += fullAddress;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Just in case the parser failed...
|
||||
if (strlen(curName))
|
||||
{
|
||||
allRecipients += curName;
|
||||
allRecipients += ' ';
|
||||
}
|
||||
if (strlen(curName))
|
||||
{
|
||||
allRecipients += curName;
|
||||
allRecipients += ' ';
|
||||
}
|
||||
|
||||
if (strlen(curAddress))
|
||||
{
|
||||
allRecipients += '<';
|
||||
allRecipients += curAddress;
|
||||
allRecipients += '>';
|
||||
}
|
||||
}
|
||||
if (strlen(curAddress))
|
||||
{
|
||||
allRecipients += '<';
|
||||
allRecipients += curAddress;
|
||||
allRecipients += '>';
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgHdr::SetRecipientsArray(const char *names, const char *addresses, PRUint32 numAddresses)
|
||||
|
|
|
@ -588,82 +588,73 @@ nsresult Tokenizer::stripHTML(const nsAString& inString, nsAString& outString)
|
|||
return parser->Parse(inString, 0, NS_LITERAL_CSTRING("text/html"), PR_TRUE);
|
||||
}
|
||||
|
||||
void Tokenizer::tokenize(char* aText)
|
||||
void Tokenizer::tokenize(const char* aText)
|
||||
{
|
||||
PR_LOG(BayesianFilterLogModule, PR_LOG_ALWAYS, ("tokenize: %s", aText));
|
||||
PR_LOG(BayesianFilterLogModule, PR_LOG_ALWAYS, ("tokenize: %s", aText));
|
||||
|
||||
// strip out HTML tags before we begin processing
|
||||
// uggh but first we have to blow up our string into UCS2
|
||||
// since that's what the document encoder wants. UTF8/UCS2, I wish we all
|
||||
// spoke the same language here..
|
||||
nsString text = NS_ConvertUTF8toUTF16(aText);
|
||||
nsString strippedUCS2;
|
||||
stripHTML(text, strippedUCS2);
|
||||
// strip out HTML tags before we begin processing
|
||||
// uggh but first we have to blow up our string into UCS2
|
||||
// since that's what the document encoder wants. UTF8/UCS2, I wish we all
|
||||
// spoke the same language here..
|
||||
nsString text = NS_ConvertUTF8toUTF16(aText);
|
||||
nsString strippedUCS2;
|
||||
stripHTML(text, strippedUCS2);
|
||||
|
||||
// convert 0x3000(full width space) into 0x0020
|
||||
nsString::iterator substr_start, substr_end;
|
||||
strippedUCS2.BeginWriting(substr_start);
|
||||
strippedUCS2.EndWriting(substr_end);
|
||||
while (substr_start != substr_end) {
|
||||
if (*substr_start == 0x3000)
|
||||
*substr_start = 0x0020;
|
||||
++substr_start;
|
||||
}
|
||||
// convert 0x3000(full width space) into 0x0020
|
||||
nsString::iterator substr_start, substr_end;
|
||||
strippedUCS2.BeginWriting(substr_start);
|
||||
strippedUCS2.EndWriting(substr_end);
|
||||
while (substr_start != substr_end) {
|
||||
if (*substr_start == 0x3000)
|
||||
*substr_start = 0x0020;
|
||||
++substr_start;
|
||||
}
|
||||
|
||||
nsCString strippedStr = NS_ConvertUTF16toUTF8(strippedUCS2);
|
||||
char * strippedText = (char *) strippedStr.get(); // bleh
|
||||
PR_LOG(BayesianFilterLogModule, PR_LOG_ALWAYS, ("tokenize stripped html: %s", strippedText));
|
||||
nsCString strippedStr = NS_ConvertUTF16toUTF8(strippedUCS2);
|
||||
char * strippedText = strippedStr.BeginWriting();
|
||||
PR_LOG(BayesianFilterLogModule, PR_LOG_ALWAYS, ("tokenize stripped html: %s", strippedText));
|
||||
|
||||
char* word;
|
||||
char* next = strippedText;
|
||||
while ((word = nsCRT::strtok(next, kBayesianFilterTokenDelimiters, &next)) != NULL) {
|
||||
if (!*word) continue;
|
||||
if (isDecimalNumber(word)) continue;
|
||||
if (isASCII(word))
|
||||
tokenize_ascii_word(word);
|
||||
else if (isJapanese(word))
|
||||
tokenize_japanese_word(word);
|
||||
else {
|
||||
nsresult rv;
|
||||
// use I18N scanner to break this word into meaningful semantic units.
|
||||
if (!mScanner) {
|
||||
mScanner = do_CreateInstance(NS_SEMANTICUNITSCANNER_CONTRACTID, &rv);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "couldn't create semantic unit scanner!");
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
char* word;
|
||||
char* next = strippedText;
|
||||
while ((word = nsCRT::strtok(next, kBayesianFilterTokenDelimiters, &next)) != NULL) {
|
||||
if (!*word) continue;
|
||||
if (isDecimalNumber(word)) continue;
|
||||
if (isASCII(word))
|
||||
tokenize_ascii_word(word);
|
||||
else if (isJapanese(word))
|
||||
tokenize_japanese_word(word);
|
||||
else {
|
||||
nsresult rv;
|
||||
// use I18N scanner to break this word into meaningful semantic units.
|
||||
if (!mScanner) {
|
||||
mScanner = do_CreateInstance(NS_SEMANTICUNITSCANNER_CONTRACTID, &rv);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "couldn't create semantic unit scanner!");
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
if (mScanner) {
|
||||
mScanner->Start("UTF-8");
|
||||
// convert this word from UTF-8 into UCS2.
|
||||
NS_ConvertUTF8toUTF16 uword(word);
|
||||
ToLowerCase(uword);
|
||||
const PRUnichar* utext = uword.get();
|
||||
PRInt32 len = uword.Length(), pos = 0, begin, end;
|
||||
PRBool gotUnit;
|
||||
while (pos < len) {
|
||||
rv = mScanner->Next(utext, len, pos, PR_TRUE, &begin, &end, &gotUnit);
|
||||
if (NS_SUCCEEDED(rv) && gotUnit) {
|
||||
NS_ConvertUTF16toUTF8 utfUnit(utext + begin, end - begin);
|
||||
add(utfUnit.get());
|
||||
// advance to end of current unit.
|
||||
pos = end;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (mScanner) {
|
||||
mScanner->Start("UTF-8");
|
||||
// convert this word from UTF-8 into UCS2.
|
||||
NS_ConvertUTF8toUTF16 uword(word);
|
||||
ToLowerCase(uword);
|
||||
const PRUnichar* utext = uword.get();
|
||||
PRInt32 len = uword.Length(), pos = 0, begin, end;
|
||||
PRBool gotUnit;
|
||||
while (pos < len) {
|
||||
rv = mScanner->Next(utext, len, pos, PR_TRUE, &begin, &end, &gotUnit);
|
||||
if (NS_SUCCEEDED(rv) && gotUnit) {
|
||||
NS_ConvertUTF16toUTF8 utfUnit(utext + begin, end - begin);
|
||||
add(utfUnit.get());
|
||||
// advance to end of current unit.
|
||||
pos = end;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Tokenizer::tokenize(const char* str)
|
||||
{
|
||||
char* text = nsCRT::strdup(str);
|
||||
if (text) {
|
||||
tokenize(text);
|
||||
nsCRT::free(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Tokenizer::visit(PRBool (*f) (Token*, void*), void* data)
|
||||
|
@ -911,9 +902,8 @@ NS_IMETHODIMP TokenStreamListener::OnStopRequest(nsIRequest *aRequest, nsISuppor
|
|||
{
|
||||
if (mLeftOverCount) {
|
||||
/* assume final buffer is complete. */
|
||||
char* buffer = mBuffer;
|
||||
buffer[mLeftOverCount] = '\0';
|
||||
mTokenizer.tokenize(buffer);
|
||||
mBuffer[mLeftOverCount] = '\0';
|
||||
mTokenizer.tokenize(mBuffer);
|
||||
}
|
||||
|
||||
/* finally, analyze the tokenized message. */
|
||||
|
|
|
@ -100,17 +100,8 @@ public:
|
|||
*/
|
||||
nsresult clearTokens();
|
||||
|
||||
/**
|
||||
* Assumes that text is mutable and
|
||||
* can be nsCRT::strtok'd.
|
||||
*/
|
||||
void tokenize(char* text);
|
||||
|
||||
/**
|
||||
* Copies the string before tokenizing.
|
||||
*/
|
||||
void tokenize(const char* str);
|
||||
|
||||
void tokenize(const char* text);
|
||||
|
||||
/**
|
||||
* Creates specific tokens based on the mime headers for the message being tokenized
|
||||
*/
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
#include "nsMsgMimeCID.h"
|
||||
#include "nsIMsgAccountManager.h"
|
||||
#include "nsMsgBaseCID.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "prmem.h"
|
||||
#include "prprf.h"
|
||||
|
|
|
@ -1018,7 +1018,7 @@ NS_IMETHODIMP nsMsgComposeSecure::MimeCryptoWriteBlock (const char *buf, PRInt32
|
|||
this function is called a line at a time. That happens to be the
|
||||
case.)
|
||||
*/
|
||||
if (size >= 5 && buf[0] == 'F' && !nsCRT::strncmp(buf, "From ", 5)) {
|
||||
if (size >= 5 && buf[0] == 'F' && !strncmp(buf, "From ", 5)) {
|
||||
char mangle[] = ">";
|
||||
status = MimeCryptoWriteBlock (mangle, 1);
|
||||
if (status < 0)
|
||||
|
|
|
@ -45,7 +45,6 @@
|
|||
#include "nsIX509CertDB.h"
|
||||
#include "nsIX509CertValidity.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsSMimeJSHelper, nsISMimeJSHelper)
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче