--- a/mailnews/import/applemail/src/nsAppleMailImport.cpp
+++ b/mailnews/import/applemail/src/nsAppleMailImport.cpp
@@ -608,18 +608,20 @@ NS_IMETHODIMP nsAppleMailImportMail::Imp
void nsAppleMailImportMail::ReportStatus(PRInt32 aErrorNum, nsString &aName, nsAString &aStream)
{
// get (and format, if needed) the error string from the bundle
nsAutoString outString;
const PRUnichar *fmt = { aName.get() };
nsresult rv = mBundle->FormatStringFromID(aErrorNum, &fmt, 1, getter_Copies(outString));
// write it out the stream
- if (NS_SUCCEEDED(rv))
- aStream.Append(outString + NS_LITERAL_STRING("\n"));
+ if (NS_SUCCEEDED(rv)) {
+ aStream.Append(outString);
+ aStream.Append(PRUnichar('\n'));
+ }
}
void nsAppleMailImportMail::SetLogs(const nsAString &aSuccess, const nsAString &aError, PRUnichar **aOutSuccess, PRUnichar **aOutError)
{
if (aOutError && !*aOutError)
*aOutError = ToNewUnicode(aError);
if (aOutSuccess && !*aOutSuccess)
*aOutSuccess = ToNewUnicode(aSuccess);
--- a/mailnews/import/build/Makefile.in
+++ b/mailnews/import/build/Makefile.in
@@ -39,19 +39,21 @@ DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = import
LIBRARY_NAME = import
+IS_COMPONENT = 1
+ifdef MOZ_INCOMPLETE_EXTERNAL_LINKAGE
+FORCE_SHARED_LIB=1
+else
EXPORT_LIBRARY = 1
-IS_COMPONENT = 1
-ifndef MOZ_INCOMPLETE_EXTERNAL_LINKAGE
MOZILLA_INTERNAL_API = 1
LIBXUL_LIBRARY = 1
endif
MODULE_NAME = nsImportServiceModule
CPPSRCS = nsImportModule.cpp
@@ -106,21 +108,24 @@ ifdef MOZILLA_INTERNAL_API
EXTRA_DSO_LDOPTS += \
$(LIBS_DIR) \
$(EXTRA_DSO_LIBS) \
$(MOZ_UNICHARUTIL_LIBS) \
$(MOZDEPTH)/modules/libreg/src/$(LIB_PREFIX)mozreg_s.$(LIB_SUFFIX) \
$(MOZ_COMPONENT_LIBS) \
$(NULL)
else
-EXTRA_DSO_LDOPTS = \
+EXTRA_DSO_LDOPTS += \
$(LIBS_DIR) \
- $(EXTRA_DSO_LIBS) \
+ $(ZLIB_LIBS) \
+ $(MOZ_ZLIB_LIBS) \
+ $(MOZ_JS_LIBS) \
$(XPCOM_GLUE_LDOPTS) \
$(call EXPAND_LIBNAME_PATH,unicharutil_external_s,$(LIBXUL_DIST)/lib) \
+ $(MOZDEPTH)/rdf/util/src/$(LIB_PREFIX)rdfutil_external_s.$(LIB_SUFFIX) \
$(MOZDEPTH)/modules/libreg/src/$(LIB_PREFIX)mozreg_s.$(LIB_SUFFIX) \
$(NSPR_LIBS) \
$(NULL)
endif
ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
EXTRA_DSO_LDOPTS += \
-framework Cocoa \
--- a/mailnews/import/comm4x/src/nsComm4xMail.cpp
+++ b/mailnews/import/comm4x/src/nsComm4xMail.cpp
@@ -44,16 +44,18 @@
#include "nsIImportMailboxDescriptor.h"
#include "nsComm4xMailStringBundle.h"
#include "nsComm4xMailImport.h"
#include "nsUnicharUtils.h"
#include "Comm4xMailDebugLog.h"
#include "prmem.h"
#include "nsNativeCharsetUtils.h"
#include "nsServiceManagerUtils.h"
+#include "nsComponentManagerUtils.h"
+#include "nsMsgUtils.h"
#define kCopyBufferSize 8192
#define kMailReadBufferSize 16384
static bool
nsShouldIgnoreFile(nsString& name)
{
--- a/mailnews/import/comm4x/src/nsComm4xProfile.cpp
+++ b/mailnews/import/comm4x/src/nsComm4xProfile.cpp
@@ -36,16 +36,17 @@
* ***** END LICENSE BLOCK ***** */
#include "nsCOMPtr.h"
#include "nsComm4xProfile.h"
#include "nsIFileStreams.h"
#include "nsILineInputStream.h"
#include "nsNetCID.h"
#include "nsDirectoryServiceDefs.h"
+#include "nsDirectoryServiceUtils.h"
#include "NSReg.h"
#include "nsComponentManagerUtils.h"
#ifdef XP_UNIX
#include <limits.h>
#endif
#if defined(XP_MACOSX)
@@ -123,17 +124,17 @@ nsComm4xProfile::GetProfileList(PRUint32
while (!NR_RegEnumSubkeys(reg, ROOTKEY_USERS, &enumstate,
profileName, MAXREGNAMELEN, REGENUM_CHILDREN))
numProfileEntries++;
// reset our enumerator
enumstate = 0;
PRUnichar **outArray, **next;
- next = outArray = (PRUnichar **)nsMemory::Alloc(numProfileEntries * sizeof(PRUnichar *));
+ next = outArray = (PRUnichar **)NS_Alloc(numProfileEntries * sizeof(PRUnichar *));
if (!outArray)
return NS_ERROR_OUT_OF_MEMORY;
while (!NR_RegEnumSubkeys(reg, ROOTKEY_USERS, &enumstate,
profileName, MAXREGNAMELEN, REGENUM_CHILDREN)) {
*next = ToNewUnicode(NS_ConvertUTF8toUTF16(profileName));
next++;
localLength++;
--- a/mailnews/import/eudora/src/nsEudoraAddress.cpp
+++ b/mailnews/import/eudora/src/nsEudoraAddress.cpp
@@ -40,19 +40,18 @@
#include "nsEudoraAddress.h"
#include "nsIAddrDatabase.h"
#include "mdb.h"
#include "nsAbBaseCID.h"
#include "nsIAbCard.h"
#include "nsIServiceManager.h"
#include "nsEudoraImport.h"
-#include "nsReadableUtils.h"
-#include "nsMsgI18N.h"
-#include "nsNativeCharsetUtils.h"
+#include "nsEudoraCompose.h"
+#include "nsMsgUtils.h"
#include "nsTextFormatter.h"
#include "nsEudoraStringBundle.h"
#include "nsIStringBundle.h"
#include "nsNetUtil.h"
#include "nsILineInputStream.h"
#include "EudoraDebugLog.h"
#define kWhitespace " \t\b\r\n"
@@ -554,18 +553,18 @@ bool CAliasData::Process( const char *pL
if (tCnt == -1) {
if (!str.IsEmpty()) {
m_email = str;
return( PR_TRUE);
}
return( PR_FALSE);
}
- str.Right( m_email, str.Length() - tCnt - 1);
- str.Left( m_realName, tCnt);
+ m_email = Substring(str, tCnt + 1);
+ m_realName = StringHead(str, tCnt);
m_realName.Trim( kWhitespace);
m_email.Trim( kWhitespace);
return( !m_email.IsEmpty());
}
#ifdef IMPORT_DEBUG
void DumpAliasArray( nsVoidArray& a)
@@ -738,63 +737,55 @@ void nsEudoraAddress::ExtractNoteField(
*/
PRInt32 idx = note.Find( field);
if (idx != -1) {
idx += field.Length();
PRInt32 endIdx = note.FindChar( '>', idx);
if (endIdx == -1)
endIdx = note.Length() - 1;
- note.Mid( value, idx, endIdx - idx);
+ value = Substring(note, idx, endIdx - idx);
idx -= field.Length();
- nsCString tempL;
- if (idx)
- note.Left( tempL, idx);
- nsCString tempR;
- note.Right( tempR, note.Length() - endIdx - 1);
- note = tempL;
- note.Append( tempR);
+ note.Cut(idx, endIdx + 1);
}
}
void nsEudoraAddress::FormatExtraDataInNoteField(PRInt32 labelStringID, nsCString& extraData, nsString& noteUTF16)
{
nsAutoString label;
nsEudoraStringBundle::GetStringByID(labelStringID, label);
noteUTF16.Append(label);
noteUTF16.AppendLiteral("\n");
noteUTF16.Append( NS_ConvertASCIItoUTF16(extraData) );
noteUTF16.AppendLiteral("\n\n");
}
void nsEudoraAddress::SanitizeValue( nsCString& val)
{
- val.ReplaceSubstring( "\n", ", ");
- val.ReplaceChar( 13, ',');
- val.ReplaceChar( 10, ',');
+ MsgReplaceSubstring(val, "\n", ", ");
+ MsgReplaceChar(val, '\r', ',');
}
void nsEudoraAddress::SplitString( nsCString& val1, nsCString& val2)
{
nsCString temp;
// Find the last line if there is more than one!
PRInt32 idx = val1.RFind( "\x0D\x0A");
PRInt32 cnt = 2;
if (idx == -1) {
cnt = 1;
idx = val1.RFindChar( 13);
}
if (idx == -1)
idx= val1.RFindChar( 10);
if (idx != -1) {
- val1.Right( val2, val1.Length() - idx - cnt);
- val1.Left( temp, idx);
- val1 = temp;
+ val2 = Substring(val1, idx + cnt);
+ val1.SetLength(idx);
SanitizeValue( val1);
}
}
void nsEudoraAddress::AddSingleCard( CAliasEntry *pEntry, nsVoidArray &emailList, nsIAddrDatabase *pDb)
{
// We always have a nickname and everything else is optional.
// Map both home and work related fields to our address card. Eudora
@@ -852,52 +843,51 @@ void nsEudoraAddress::AddSingleCard( CAl
// in the notes field?
if ( !additionalEmail.IsEmpty() || !otherPhone.IsEmpty() || !otherWeb.IsEmpty() )
{
nsCString otherNotes(note);
if ( !additionalEmail.IsEmpty() )
{
// Reconstitute line breaks for additional email
- additionalEmail.ReplaceSubstring( "\x03", "\n");
+ MsgReplaceSubstring(additionalEmail, "\x03", "\n");
// Try to figure out if there are multiple email addresses in additionalEmail
- PRInt32 idx = additionalEmail.FindCharInSet("\t\r\n,; ");
+ PRInt32 idx = MsgFindCharInSet(additionalEmail, "\t\r\n,; ");
if (idx != -1)
{
// We found a character that indicates that there's more than one email address here.
// Separate out the addresses after the first one.
- additionalEmail.Right(stillMoreEmail, additionalEmail.Length() - idx - 1);
+ stillMoreEmail = Substring(additionalEmail, idx + 1);
stillMoreEmail.Trim(kWhitespace);
// Separate out the first address.
- nsCString tempStashEmail(additionalEmail);
- tempStashEmail.Left(additionalEmail, idx);
+ additionalEmail.SetLength(idx);
}
// If there were more than one additional email addresses store all the extra
// ones in the notes field, labeled nicely.
if ( !stillMoreEmail.IsEmpty() )
FormatExtraDataInNoteField(EUDORAIMPORT_ADDRESS_LABEL_OTHEREMAIL, stillMoreEmail, noteUTF16);
}
if ( !otherPhone.IsEmpty() )
{
// Reconstitute line breaks for other phone numbers
- otherPhone.ReplaceSubstring( "\x03", "\n");
+ MsgReplaceSubstring(otherPhone, "\x03", "\n");
// Store other phone numbers in the notes field, labeled nicely
FormatExtraDataInNoteField(EUDORAIMPORT_ADDRESS_LABEL_OTHERPHONE, otherPhone, noteUTF16);
}
if ( !otherWeb.IsEmpty() )
{
// Reconstitute line breaks for other web sites
- otherWeb.ReplaceSubstring( "\x03", "\n");
+ MsgReplaceSubstring(otherWeb, "\x03", "\n");
// Store other web sites in the notes field, labeled nicely
FormatExtraDataInNoteField(EUDORAIMPORT_ADDRESS_LABEL_OTHERWEB, otherWeb, noteUTF16);
}
noteUTF16.Append( NS_ConvertASCIItoUTF16(note) );
}
}
@@ -906,37 +896,37 @@ void nsEudoraAddress::AddSingleCard( CAl
if (pData && !pData->m_realName.IsEmpty())
displayName = pData->m_realName;
else if (!name.IsEmpty())
displayName = name;
else
displayName = pEntry->m_name;
- address.ReplaceSubstring( "\x03", "\n");
+ MsgReplaceSubstring(address, "\x03", "\n");
SplitString( address, address2);
- note.ReplaceSubstring( "\x03", "\n");
- fax.ReplaceSubstring( "\x03", " ");
- secondaryFax.ReplaceSubstring( "\x03", " ");
- phone.ReplaceSubstring( "\x03", " ");
- name.ReplaceSubstring( "\x03", " ");
- city.ReplaceSubstring( "\x03", " ");
- state.ReplaceSubstring( "\x03", " ");
- zip.ReplaceSubstring( "\x03", " ");
- country.ReplaceSubstring( "\x03", " ");
+ MsgReplaceSubstring(note, "\x03", "\n");
+ MsgReplaceSubstring(fax, "\x03", " ");
+ MsgReplaceSubstring(secondaryFax, "\x03", " ");
+ MsgReplaceSubstring(phone, "\x03", " ");
+ MsgReplaceSubstring(name, "\x03", " ");
+ MsgReplaceSubstring(city, "\x03", " ");
+ MsgReplaceSubstring(state, "\x03", " ");
+ MsgReplaceSubstring(zip, "\x03", " ");
+ MsgReplaceSubstring(country, "\x03", " ");
- addressWK.ReplaceSubstring( "\x03", "\n");
+ MsgReplaceSubstring(addressWK, "\x03", "\n");
SplitString( addressWK, address2WK);
- phoneWK.ReplaceSubstring( "\x03", " ");
- cityWK.ReplaceSubstring( "\x03", " ");
- stateWK.ReplaceSubstring( "\x03", " ");
- zipWK.ReplaceSubstring( "\x03", " ");
- countryWK.ReplaceSubstring( "\x03", " ");
- title.ReplaceSubstring( "\x03", " ");
- company.ReplaceSubstring( "\x03", " ");
+ MsgReplaceSubstring(phoneWK, "\x03", " ");
+ MsgReplaceSubstring(cityWK, "\x03", " ");
+ MsgReplaceSubstring(stateWK, "\x03", " ");
+ MsgReplaceSubstring(zipWK, "\x03", " ");
+ MsgReplaceSubstring(countryWK, "\x03", " ");
+ MsgReplaceSubstring(title, "\x03", " ");
+ MsgReplaceSubstring(company, "\x03", " ");
if (newRow)
{
nsAutoString uniStr;
// Home related fields.
ADD_FIELD_TO_DB_ROW(pDb, AddDisplayName, newRow, displayName, uniStr);
ADD_FIELD_TO_DB_ROW(pDb, AddNickName, newRow, pEntry->m_name, uniStr);
@@ -960,17 +950,17 @@ void nsEudoraAddress::AddSingleCard( CAl
ADD_FIELD_TO_DB_ROW(pDb, AddWorkPhone, newRow, phoneWK, uniStr);
ADD_FIELD_TO_DB_ROW(pDb, AddWorkAddress, newRow, addressWK, uniStr);
ADD_FIELD_TO_DB_ROW(pDb, AddWorkAddress2, newRow, address2WK, uniStr);
ADD_FIELD_TO_DB_ROW(pDb, AddWorkCity, newRow, cityWK, uniStr);
ADD_FIELD_TO_DB_ROW(pDb, AddWorkZipCode, newRow, zipWK, uniStr);
ADD_FIELD_TO_DB_ROW(pDb, AddWorkState, newRow, stateWK, uniStr);
ADD_FIELD_TO_DB_ROW(pDb, AddWorkCountry, newRow, countryWK, uniStr);
- if ( (primaryLocation.IsEmpty() || primaryLocation.LowerCaseEqualsASCII("home")) &&
+ if ( (primaryLocation.IsEmpty() || primaryLocation.LowerCaseEqualsLiteral("home")) &&
!mobile.IsEmpty() )
{
// Primary location field is either specified to be "home" or is not
// specified and there is a home mobile number, so use that as the mobile number.
ADD_FIELD_TO_DB_ROW(pDb, AddCellularNumber, newRow, mobile, uniStr);
isSecondaryMobileWorkNumber = PR_TRUE;
}
@@ -980,17 +970,17 @@ void nsEudoraAddress::AddSingleCard( CAl
// home mobile number, so use work mobile number.
ADD_FIELD_TO_DB_ROW(pDb, AddCellularNumber, newRow, secondaryMobile, uniStr);
// Home mobile number (if any) is the secondary mobile number
secondaryMobile = mobile;
isSecondaryMobileWorkNumber = PR_FALSE;
}
- if ( (primaryLocation.IsEmpty() || primaryLocation.LowerCaseEqualsASCII("home")) &&
+ if ( (primaryLocation.IsEmpty() || primaryLocation.LowerCaseEqualsLiteral("home")) &&
!fax.IsEmpty() )
{
// Primary location field is either specified to be "home" or is not
// specified and there is a home fax number, so use that as the fax number.
ADD_FIELD_TO_DB_ROW(pDb, AddFaxNumber, newRow, fax, uniStr);
isSecondaryFaxWorkNumber = PR_TRUE;
}
@@ -1130,17 +1120,18 @@ nsresult nsEudoraAddress::AddSingleList(
rv = pDb->AddListNickName(newRow, pEntry->m_name.get());
NS_ENSURE_SUCCESS(rv, rv);
// Now add the members.
PRInt32 max = emailList.Count();
for (PRInt32 i = 0; i < max; i++)
{
CAliasData *pData = (CAliasData *)emailList.ElementAt(i);
- nsCAutoString ldifValue(NS_LITERAL_CSTRING("mail=") + nsDependentCString(pData->m_email.get()));
+ nsCAutoString ldifValue("mail");
+ ldifValue.Append(pData->m_email);
rv = pDb->AddLdifListMember(newRow, ldifValue.get());
}
rv = pDb->AddCardRowToDB(newRow);
NS_ENSURE_SUCCESS(rv, rv);
rv = pDb->AddListDirNode(newRow);
return rv;
--- a/mailnews/import/eudora/src/nsEudoraAddress.h
+++ b/mailnews/import/eudora/src/nsEudoraAddress.h
@@ -35,17 +35,17 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsEudoraAddress_h__
#define nsEudoraAddress_h__
#include "nscore.h"
-#include "nsString.h"
+#include "nsStringGlue.h"
#include "nsVoidArray.h"
#include "nsILocalFile.h"
#include "nsISupportsArray.h"
#include "nsCOMPtr.h"
#include "nsIImportService.h"
class nsIAddrDatabase;
--- a/mailnews/import/eudora/src/nsEudoraCompose.cpp
+++ b/mailnews/import/eudora/src/nsEudoraCompose.cpp
@@ -34,18 +34,18 @@
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nscore.h"
#include "prthread.h"
-#include "nsString.h"
-#include "nsReadableUtils.h"
+#include "nsStringGlue.h"
+#include "nsMsgUtils.h"
#include "nsUnicharUtils.h"
#include "nsCOMPtr.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsIIOService.h"
#include "nsIURI.h"
#include "nsIOutputStream.h"
#include "nsThreadUtils.h"
@@ -62,17 +62,16 @@
#include "nsNetCID.h"
#include "nsEudoraCompose.h"
#include "nsEudoraEditor.h"
#include "EudoraDebugLog.h"
#include "nsMimeTypes.h"
-#include "nsMsgUtils.h"
#include "nsNetUtil.h"
#include "nsAutoPtr.h"
#include "nsIMutableArray.h"
static NS_DEFINE_CID( kMsgSendCID, NS_MSGSEND_CID);
static NS_DEFINE_CID( kMsgCompFieldsCID, NS_MSGCOMPFIELDS_CID);
// We need to do some calculations to set these numbers to something reasonable!
@@ -457,60 +456,52 @@ void nsEudoraCompose::GetHeaderValue( co
}
val.Trim( kWhitespace);
}
void nsEudoraCompose::ExtractCharset( nsString& str)
{
- nsString tStr;
- PRInt32 idx = str.Find( "charset=", PR_TRUE);
+ PRInt32 idx = MsgFind(str, "charset=", PR_TRUE, 0);
if (idx != -1) {
- idx += 8;
- str.Right( tStr, str.Length() - idx);
- idx = tStr.FindChar( ';');
+ str.Cut(0, idx + 8);
+ idx = str.FindChar( ';');
if (idx != -1)
- tStr.Left( str, idx);
- else
- str = tStr;
+ str.SetLength(idx);
str.Trim( kWhitespace);
if ((str.CharAt( 0) == '"') && (str.Length() > 2)) {
- str.Mid( tStr, 1, str.Length() - 2);
- str = tStr;
+ str.SetLength(str.Length() - 1);
+ str.Cut(0, 1);
str.Trim( kWhitespace);
}
}
else
str.Truncate();
}
void nsEudoraCompose::ExtractType( nsString& str)
{
nsString tStr;
PRInt32 idx = str.FindChar( ';');
- if (idx != -1) {
- str.Left( tStr, idx);
- str = tStr;
- }
+ if (idx != -1)
+ str.SetLength(idx);
+
str.Trim( kWhitespace);
if ((str.CharAt( 0) == '"') && (str.Length() > 2)) {
- str.Mid( tStr, 1, str.Length() - 2);
- str = tStr;
+ str.SetLength(str.Length() - 1);
+ str.Cut(0, 1);
str.Trim( kWhitespace);
}
// if multipart then ignore it since no outlook message body is ever
// valid multipart!
- if (str.Length() > 10) {
- str.Left( tStr, 10);
- if (tStr.LowerCaseEqualsLiteral("multipart/"))
- str.Truncate();
- }
+ if (StringBeginsWith(str, NS_LITERAL_STRING("multipart/"), nsCaseInsensitiveStringComparator()))
+ str.Truncate();
}
nsresult nsEudoraCompose::GetLocalAttachments(nsIArray **aArray)
{
/*
nsIURI *url = nsnull;
*/
nsresult rv;
@@ -586,17 +577,17 @@ nsresult nsEudoraCompose::SendTheMessage
// Use platform charset as default if the msg doesn't specify one
// (ie, no 'charset' param in the Content-Type: header). As the last
// resort we'll use the mail default charset.
// (ie, no 'charset' param in the Content-Type: header) or if the
// charset parameter fails a length sanity check.
// As the last resort we'll use the mail default charset.
if ( headerVal.IsEmpty() || (headerVal.Length() > kContentTypeLengthSanityCheck) )
{
- CopyASCIItoUTF16(nsMsgI18NFileSystemCharset(), headerVal);
+ headerVal.AssignASCII(nsMsgI18NFileSystemCharset());
if (headerVal.IsEmpty())
{ // last resort
if (m_defCharset.IsEmpty())
{
nsString defaultCharset;
NS_GetLocalizedUnicharPreferenceWithDefault(nsnull, "mailnews.view_default_charset",
NS_LITERAL_STRING("ISO-8859-1"), defaultCharset);
m_defCharset = defaultCharset;
@@ -614,17 +605,17 @@ nsresult nsEudoraCompose::SendTheMessage
m_pMsgFields->SetMessageId( NS_LossyConvertUTF16toASCII(headerVal).get() );
GetHeaderValue( m_pHeaders, m_headerLen, "Reply-To:", headerVal);
if (!headerVal.IsEmpty())
m_pMsgFields->SetReplyTo( headerVal);
// what about all of the other headers?!?!?!?!?!?!
char *pMimeType;
if (!bodyType.IsEmpty())
- pMimeType = ToNewCString(bodyType);
+ pMimeType = ToNewCString(NS_LossyConvertUTF16toASCII(bodyType));
else
pMimeType = ToNewCString(m_bodyType);
// IMPORT_LOG0( "Outlook compose calling CreateAndSendMessage\n");
nsCOMPtr<nsIArray> pAttach;
GetLocalAttachments(getter_AddRefs(pAttach));
/*
--- a/mailnews/import/eudora/src/nsEudoraCompose.h
+++ b/mailnews/import/eudora/src/nsEudoraCompose.h
@@ -36,23 +36,30 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsEudoraCompose_h__
#define nsEudoraCompose_h__
#include "nscore.h"
#include "nsCOMPtr.h"
-#include "nsString.h"
+#include "nsStringGlue.h"
+#include "nsMsgUtils.h"
#include "nsIFile.h"
#include "nsIInputStream.h"
#include "nsVoidArray.h"
#include "nsIImportService.h"
+
+#ifdef MOZILLA_INTERNAL_API
#include "nsNativeCharsetUtils.h"
-
+#else
+#include "nsMsgI18N.h"
+#define NS_CopyNativeToUnicode(source, dest) \
+ nsMsgI18NConvertToUnicode(nsMsgI18NFileSystemCharset(), source, dest)
+#endif
class nsIMsgSend;
class nsIMsgCompFields;
class nsIMsgIdentity;
class nsIMsgSendListener;
class nsIIOService;
#include "nsIMsgSend.h"
--- a/mailnews/import/eudora/src/nsEudoraEditor.cpp
+++ b/mailnews/import/eudora/src/nsEudoraEditor.cpp
@@ -36,17 +36,18 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsEudoraEditor.h"
#include "nsISupportsArray.h"
#include "nsIDOMHTMLImageElement.h"
#include "nsComponentManagerUtils.h"
-#include "nsString.h"
+#include "nsStringGlue.h"
+#include "nsMsgUtils.h"
#include "nsNetUtil.h"
NS_IMPL_ISUPPORTS2(nsEudoraEditor, nsIEditor, nsIEditorMailSupport)
NS_IMPL_ISUPPORTS4(nsEudoraHTMLImageElement, nsIDOMNode, nsIDOMElement, nsIDOMHTMLElement, nsIDOMHTMLImageElement)
static char * sEudoraEmbeddedContentLines[] = {
"Embedded Content: ",
@@ -736,22 +737,20 @@ NS_IMETHODIMP nsEudoraEditor::GetEmbedde
{
// Found this translation of "Embedded Content" - remember that so that we don't
// bother looking for any other translations.
foundEmbeddedContentLines = PR_TRUE;
// Extract the file name from the embedded content line
PRInt32 startFileName = startEmbeddedContentLine + lenEmbeddedContentTag;
PRInt32 endFileName = m_body.Find(":", PR_FALSE, startFileName);
- nsString fileName;
- m_body.Mid(fileName, startFileName, endFileName - startFileName);
// Create the file spec for the embedded image
embeddedFolderSpec->Clone(getter_AddRefs(embeddedImageSpec));
- embeddedImageSpec->Append(fileName);
+ embeddedImageSpec->Append(Substring(m_body, startFileName, endFileName - startFileName));
// Verify that the embedded image spec exists and is a file
bool isFile = false;
bool exists = false;
if ( NS_FAILED(embeddedImageSpec->Exists( &exists)) || NS_FAILED(embeddedImageSpec->IsFile(&isFile)) )
continue;
if (!exists || !isFile)
continue;
@@ -762,23 +761,23 @@ NS_IMETHODIMP nsEudoraEditor::GetEmbedde
if (startCIDHash != kNotFound)
{
startCIDHash++;
PRInt32 endCIDHash = m_body.Find(",", PR_FALSE, startCIDHash);
if (endCIDHash != kNotFound)
{
nsString cidHash;
- m_body.Mid(cidHash, startCIDHash, endCIDHash - startCIDHash);
+ cidHash.Assign(Substring(m_body, startCIDHash, endCIDHash - startCIDHash));
if ( !cidHash.IsEmpty() )
{
// Convert CID hash string to numeric value
- PRInt32 aErrorCode;
- cidHashValue = cidHash.ToInteger(&aErrorCode, kRadix16);
+ nsresult aErrorCode;
+ cidHashValue = cidHash.ToInteger(&aErrorCode, 16);
}
}
}
// Get the URL for the embedded image
nsCString embeddedImageURL;
rv = NS_GetURLSpecFromFile(embeddedImageSpec, embeddedImageURL);
NS_ENSURE_SUCCESS(rv, rv);
@@ -852,26 +851,26 @@ bool nsEudoraEditor::UpdateEmbeddedImage
// Get the quote char and verify that it's valid
char quoteChar = static_cast <char> (m_body.CharAt(startSrcValue));
if ( (quoteChar != '"') && (quoteChar != '\'') )
continue;
// Move past the quote
++startSrcValue;
- PRInt32 endSrcValue = m_body.Find(nsCString(quoteChar), PR_FALSE, startSrcValue);
+ PRInt32 endSrcValue = m_body.FindChar(quoteChar, startSrcValue);
PRInt32 srcLength = endSrcValue - startSrcValue;
nsString srcValue;
- m_body.Mid(srcValue, startSrcValue, srcLength);
+ srcValue.Assign(Substring(m_body, startSrcValue, srcLength));
if (aCIDHash != 0)
{
// Verify source value starts with "cid:"
- if ( !srcValue.EqualsIgnoreCase("cid:", 4) )
+ if (!StringBeginsWith(srcValue, NS_LITERAL_STRING("cid:"), nsCaseInsensitiveStringComparator()))
continue;
// Remove "cid:" from the start
srcValue.Cut(0, 4);
PRUint32 hashValue = EudoraHashString( NS_LossyConvertUTF16toASCII(srcValue).get() );
foundMatch = (hashValue == aCIDHash);
}
--- a/mailnews/import/eudora/src/nsEudoraEditor.h
+++ b/mailnews/import/eudora/src/nsEudoraEditor.h
@@ -36,17 +36,17 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nscore.h"
#include "nsIEditor.h"
#include "nsIEditorMailSupport.h"
#include "nsIDOMHTMLImageElement.h"
#include "nsCOMPtr.h"
-#include "nsString.h"
+#include "nsStringGlue.h"
#include "nsIFile.h"
class nsEudoraEditor : public nsIEditor, public nsIEditorMailSupport
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIEDITOR
--- a/mailnews/import/eudora/src/nsEudoraFilters.cpp
+++ b/mailnews/import/eudora/src/nsEudoraFilters.cpp
@@ -41,16 +41,17 @@
*/
#include "nsCOMPtr.h"
#include "nscore.h"
#include "nsCRTGlue.h"
#include "nspr.h"
#include "plstr.h"
#include "nsMsgBaseCID.h"
+#include "nsMsgUtils.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIMsgFilterList.h"
#include "nsIMsgAccountManager.h"
#include "nsIStringBundle.h"
#include "nsEudoraFilters.h"
#include "nsEudoraStringBundle.h"
@@ -259,17 +260,21 @@ bool nsEudoraFilters::RealImport()
{
const char* pMailboxPath = strchr(pLine, ' ') + 1;
bool isTransfer = (*pLine == 't');
rv = AddMailboxAction(pMailboxPath, isTransfer);
if (rv == NS_ERROR_INVALID_ARG)
{
nsAutoString unicodeMailboxPath;
NS_CopyNativeToUnicode(nsCString(pMailboxPath), unicodeMailboxPath);
- m_errorLog += NS_LITERAL_STRING("- ") + name + NS_LITERAL_STRING(": ") + nsEudoraStringBundle::FormatString(EUDORAIMPORT_FILTERS_WARN_MAILBOX_MISSING, unicodeMailboxPath.get()) + NS_LITERAL_STRING("\n") ;
+ m_errorLog += NS_LITERAL_STRING("- ");
+ m_errorLog += name;
+ m_errorLog += NS_LITERAL_STRING(": ");
+ m_errorLog += nsEudoraStringBundle::FormatString(EUDORAIMPORT_FILTERS_WARN_MAILBOX_MISSING, unicodeMailboxPath.get());
+ m_errorLog += NS_LITERAL_STRING("\n");
rv = NS_OK;
}
}
// Doing strncmp() here because Win Eudora puts a space after "stop" but Mac Eudora doesn't
else if (!strncmp(pLine, "stop", 4))
m_hasStop = PR_TRUE;
else if (!strncmp(pLine, "forward ", 8))
rv = AddStringAction(nsMsgFilterAction::Forward, pLine + 8);
@@ -319,22 +324,32 @@ bool nsEudoraFilters::RealImport()
#endif
rv = AddAction(bDelete? (nsMsgRuleActionType)nsMsgFilterAction::DeleteFromPop3Server : (nsMsgRuleActionType)nsMsgFilterAction::LeaveOnPop3Server);
if (NS_SUCCEEDED(rv) && bFetch)
rv = AddAction(nsMsgFilterAction::FetchBodyFromPop3Server);
}
else if (strcmp(pLine, "manual") == 0)
;// Just ignore manual as TB handles manual in a different way
else if (strcmp(pLine, "outgoing") == 0)
- m_errorLog += NS_LITERAL_STRING("- ") + name + NS_LITERAL_STRING(": ") + nsEudoraStringBundle::FormatString(EUDORAIMPORT_FILTERS_WARN_OUTGOING) + NS_LITERAL_STRING("\n") ;
+ {
+ m_errorLog += NS_LITERAL_STRING("- ");
+ m_errorLog += name;
+ m_errorLog += NS_LITERAL_STRING(": ");
+ m_errorLog += nsEudoraStringBundle::FormatString(EUDORAIMPORT_FILTERS_WARN_OUTGOING);
+ m_errorLog += NS_LITERAL_STRING("\n");
+ }
else
{
nsAutoString unicodeLine;
NS_CopyNativeToUnicode(nsCString(pLine), unicodeLine);
- m_errorLog += NS_LITERAL_STRING("- ") + name + NS_LITERAL_STRING(": ") + nsEudoraStringBundle::FormatString(EUDORAIMPORT_FILTERS_WARN_ACTION, unicodeLine.get()) + NS_LITERAL_STRING("\n");
+ m_errorLog += NS_LITERAL_STRING("- ");
+ m_errorLog += name;
+ m_errorLog += NS_LITERAL_STRING(": ");
+ m_errorLog += nsEudoraStringBundle::FormatString(EUDORAIMPORT_FILTERS_WARN_ACTION, unicodeLine.get());
+ m_errorLog += NS_LITERAL_STRING("\n");
}
}
}
// Process the last filter
if (!more && NS_SUCCEEDED(rv))
rv = FinalizeFilter();
@@ -685,27 +700,37 @@ nsresult nsEudoraFilters::AddTerm(const
nsCAutoString arbitraryHeader;
nsAutoString unicodeHeader, unicodeVerb, unicodeValue;
nsAutoString filterTitle;
NS_CopyNativeToUnicode(nsCString(pHeader), unicodeHeader);
NS_CopyNativeToUnicode(nsCString(pVerb), unicodeVerb);
NS_CopyNativeToUnicode(nsCString(pValue), unicodeValue);
- filterTitle = NS_LITERAL_STRING("- ") + unicodeHeader + NS_LITERAL_STRING(" ") + unicodeVerb + NS_LITERAL_STRING(" ") + unicodeValue + NS_LITERAL_STRING(": ");
+ filterTitle = NS_LITERAL_STRING("- ");
+ filterTitle += unicodeHeader;
+ filterTitle += NS_LITERAL_STRING(" ");
+ filterTitle += unicodeVerb;
+ filterTitle += NS_LITERAL_STRING(" ");
+ filterTitle += unicodeValue;
+ filterTitle += NS_LITERAL_STRING(": ");
if (op < 0)
{
- m_errorLog += filterTitle + nsEudoraStringBundle::FormatString(EUDORAIMPORT_FILTERS_WARN_VERB, pVerb) + NS_LITERAL_STRING("\n");
+ m_errorLog += filterTitle;
+ m_errorLog += nsEudoraStringBundle::FormatString(EUDORAIMPORT_FILTERS_WARN_VERB, pVerb);
+ m_errorLog += NS_LITERAL_STRING("\n");
return NS_ERROR_INVALID_ARG;
}
if (!pHeader || !*pHeader)
{
- m_errorLog += filterTitle + nsEudoraStringBundle::FormatString(EUDORAIMPORT_FILTERS_WARN_EMPTY_HEADER) + NS_LITERAL_STRING("\n");
+ m_errorLog += filterTitle;
+ m_errorLog += nsEudoraStringBundle::FormatString(EUDORAIMPORT_FILTERS_WARN_EMPTY_HEADER);
+ m_errorLog += NS_LITERAL_STRING("\n");
return NS_ERROR_INVALID_ARG;
}
if (negateVerb)
{
switch (op)
{
case nsMsgSearchOp::Contains:
@@ -714,27 +739,31 @@ nsresult nsEudoraFilters::AddTerm(const
op++;
break;
case nsMsgSearchOp::DoesntContain:
case nsMsgSearchOp::Isnt:
case nsMsgSearchOp::IsntInAB:
op--;
break;
default:
- m_errorLog += filterTitle + nsEudoraStringBundle::FormatString(EUDORAIMPORT_FILTERS_WARN_NEGATE_VERB, unicodeVerb.get()) + NS_LITERAL_STRING("\n");
+ m_errorLog += filterTitle;
+ m_errorLog += nsEudoraStringBundle::FormatString(EUDORAIMPORT_FILTERS_WARN_NEGATE_VERB, unicodeVerb.get());
+ m_errorLog += NS_LITERAL_STRING("\n");
return NS_ERROR_INVALID_ARG;
}
}
if (attrib < 0)
{
// Can't handle other Eudora meta-headers (Any Header, Personality, Junk Score)
if (*pHeader == *LDAQ)
{
- m_errorLog += filterTitle + nsEudoraStringBundle::FormatString(EUDORAIMPORT_FILTERS_WARN_META_HEADER, unicodeHeader.get()) + NS_LITERAL_STRING("\n");
+ m_errorLog += filterTitle;
+ m_errorLog += nsEudoraStringBundle::FormatString(EUDORAIMPORT_FILTERS_WARN_META_HEADER, unicodeHeader.get());
+ m_errorLog += NS_LITERAL_STRING("\n");
return NS_ERROR_INVALID_ARG;
}
// Arbitrary headers for filters don't like the colon at the end
arbitraryHeader = pHeader;
PRInt32 index = arbitraryHeader.FindChar(':');
if (index >= 0)
arbitraryHeader.SetLength(index);
--- a/mailnews/import/eudora/src/nsEudoraImport.cpp
+++ b/mailnews/import/eudora/src/nsEudoraImport.cpp
@@ -45,20 +45,21 @@
*/
#ifdef MOZ_LOGGING
// sorry, this has to be before the pre-compiled header
#define FORCE_PR_LOG /* Allow logging in the release build */
#endif
#include "nscore.h"
-#include "nsString.h"
-#include "nsIServiceManager.h"
+#include "nsCOMPtr.h"
+#include "nsStringGlue.h"
+#include "nsServiceManagerUtils.h"
#include "nsIImportService.h"
-#include "nsIComponentManager.h"
+#include "nsComponentManagerUtils.h"
#include "nsEudoraImport.h"
#include "nsIMemory.h"
#include "nsIImportService.h"
#include "nsIImportMail.h"
#include "nsIImportMailboxDescriptor.h"
#include "nsIImportGeneric.h"
#include "nsIImportAddressBooks.h"
#include "nsIImportABDescriptor.h"
@@ -70,17 +71,16 @@
#include "nsIOutputStream.h"
#include "nsIAddrDatabase.h"
#include "nsTextFormatter.h"
#include "nsEudoraStringBundle.h"
#include "nsIStringBundle.h"
#include "nsEudoraCompose.h"
#include "nsEudoraSettings.h"
#include "nsEudoraFilters.h"
-#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
#include "nsIMsgTagService.h"
#include "nsMsgBaseCID.h"
#if defined(XP_WIN) || defined(XP_OS2)
#include "nsEudoraWin32.h"
#endif
--- a/mailnews/import/eudora/src/nsEudoraMac.cpp
+++ b/mailnews/import/eudora/src/nsEudoraMac.cpp
@@ -52,17 +52,16 @@
#include "nsEudoraMac.h"
#include "nsIImportService.h"
#include "nsIImportMailboxDescriptor.h"
#include "nsIImportABDescriptor.h"
#include "nsDirectoryServiceDefs.h"
#include "nsEudoraStringBundle.h"
#include "nsEudoraImport.h"
#include "nsIPop3IncomingServer.h"
-#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
#include "nsNetUtil.h"
#include "EudoraDebugLog.h"
#include "nsILocalFileMac.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
--- a/mailnews/import/eudora/src/nsEudoraMac.h
+++ b/mailnews/import/eudora/src/nsEudoraMac.h
@@ -36,17 +36,17 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsEudoraMac_h__
#define nsEudoraMac_h__
#include "nscore.h"
-#include "nsString.h"
+#include "nsStringGlue.h"
#include "nsIFile.h"
#include "nsISupportsArray.h"
#include "nsEudoraMailbox.h"
#include "nsEudoraAddress.h"
#include <CoreServices/CoreServices.h>
class nsIImportService;
--- a/mailnews/import/eudora/src/nsEudoraMailbox.cpp
+++ b/mailnews/import/eudora/src/nsEudoraMailbox.cpp
@@ -34,17 +34,16 @@
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "msgCore.h"
#include "nsCOMPtr.h"
-#include "nsReadableUtils.h"
#include "nsEudoraMailbox.h"
#include "nsDirectoryServiceDefs.h"
#include "nsEudoraCompose.h"
#include "nspr.h"
#include "nsMsgMessageFlags.h"
#include "nsMailHeaders.h"
#include "nsMsgLocalFolderHdrs.h"
--- a/mailnews/import/eudora/src/nsEudoraMailbox.h
+++ b/mailnews/import/eudora/src/nsEudoraMailbox.h
@@ -35,17 +35,17 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsEudoraMailbox_h__
#define nsEudoraMailbox_h__
#include "nscore.h"
-#include "nsString.h"
+#include "nsStringGlue.h"
#include "nsVoidArray.h"
#include "nsIFile.h"
#include "nsISupportsArray.h"
#include "nsEudoraCompose.h"
class nsIOutputStream;
/////////////////////////////////////////////////////////////////////////////////////
--- a/mailnews/import/eudora/src/nsEudoraSettings.cpp
+++ b/mailnews/import/eudora/src/nsEudoraSettings.cpp
@@ -40,17 +40,17 @@
/*
Eudora settings
*/
#include "nsCOMPtr.h"
#include "nscore.h"
#include "nsEudoraSettings.h"
#include "nsEudoraStringBundle.h"
-
+#include "nsComponentManagerUtils.h"
#include "EudoraDebugLog.h"
#if defined(XP_WIN) || defined(XP_OS2)
#include "nsEudoraWin32.h"
#endif
#ifdef XP_MACOSX
#include "nsEudoraMac.h"
#endif
--- a/mailnews/import/eudora/src/nsEudoraStringBundle.cpp
+++ b/mailnews/import/eudora/src/nsEudoraStringBundle.cpp
@@ -35,20 +35,19 @@
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "prprf.h"
#include "prmem.h"
#include "nsCOMPtr.h"
-#include "nsReadableUtils.h"
#include "nsIStringBundle.h"
#include "nsEudoraStringBundle.h"
-#include "nsIServiceManager.h"
+#include "nsServiceManagerUtils.h"
#include "nsIURI.h"
#include "nsTextFormatter.h"
#define EUDORA_MSGS_URL "chrome://messenger/locale/eudoraImportMsgs.properties"
nsIStringBundle * nsEudoraStringBundle::m_pBundle = nsnull;
nsIStringBundle *nsEudoraStringBundle::GetStringBundle( void)
--- a/mailnews/import/eudora/src/nsEudoraStringBundle.h
+++ b/mailnews/import/eudora/src/nsEudoraStringBundle.h
@@ -34,17 +34,17 @@
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsEudoraStringBundle_H__
#define nsEudoraStringBundle_H__
-#include "nsString.h"
+#include "nsStringGlue.h"
class nsIStringBundle;
class nsEudoraStringBundle {
public:
static PRUnichar * GetStringByID(PRInt32 stringID);
static void GetStringByID(PRInt32 stringID, nsString& result);
static nsString FormatString(PRInt32 stringID, ...);
--- a/mailnews/import/eudora/src/nsEudoraWin32.cpp
+++ b/mailnews/import/eudora/src/nsEudoraWin32.cpp
@@ -34,25 +34,24 @@
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsCOMPtr.h"
-#include "nsReadableUtils.h"
+#include "nsMsgUtils.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsIMsgAccountManager.h"
#include "nsIMsgAccount.h"
#include "nsIPop3IncomingServer.h"
#include "nsMsgBaseCID.h"
#include "nsMsgCompCID.h"
-#include "nsMsgI18N.h"
#include "nsISmtpService.h"
#include "nsISmtpServer.h"
#include "nsEudoraWin32.h"
#include "nsIImportService.h"
#include "nsIImportMailboxDescriptor.h"
#include "nsIImportABDescriptor.h"
#include "nsEudoraStringBundle.h"
#include "nsEudoraImport.h"
@@ -117,30 +116,27 @@ bool nsEudoraWin32::FindEudoraLocation(
{
// get the value of "Current"
BYTE *pBytes = GetValueBytes( sKey, "Current");
if (pBytes)
{
nsCString str((const char *)pBytes);
delete [] pBytes;
- str.CompressWhitespace();
+ MsgCompressWhitespace(str);
// Command line is Eudora mailfolder eudora.ini
if (findIni)
{
// find the string coming after the last space
PRInt32 index = str.RFind(" ");
if (index != -1)
{
index++; // skip the space
- nsCString path;
- str.Mid( path, index, str.Length() - index);
-
- eudoraPath->InitWithNativePath(path);
+ eudoraPath->InitWithNativePath(Substring(str, index));
eudoraPath->IsFile( &exists);
if (exists)
result = exists;
else // it may just be the mailbox location....guess that there will be a eudora.ini file there
{
eudoraPath->AppendNative(NS_LITERAL_CSTRING("eudora.ini"));
eudoraPath->IsFile( &exists);
result = exists;
@@ -165,20 +161,17 @@ bool nsEudoraWin32::FindEudoraLocation(
while (str.CharAt( idx) == ' ') idx++;
int endIdx = -1;
if (str.CharAt( idx) == '"')
endIdx = str.FindChar( '"', idx);
else
endIdx = str.FindChar( ' ', idx);
if (endIdx != -1)
{
- nsCString path;
- str.Mid( path, idx, endIdx - idx);
-
- eudoraPath->InitWithNativePath(path);
+ eudoraPath->InitWithNativePath(Substring(str, idx, endIdx - idx));
if (NS_SUCCEEDED( eudoraPath->IsDirectory( &exists)))
result = exists;
}
}
}
} // if pBytes
::RegCloseKey( sKey);
@@ -293,18 +286,18 @@ nsresult nsEudoraWin32::IterateMailDir(
if (NS_SUCCEEDED( rv))
{
rv = entry->GetNativeLeafName(fName);
if (NS_SUCCEEDED( rv) && !fName.IsEmpty())
{
if (fName.Length() > 4)
{
- fName.Right( ext, 4);
- fName.Left( name, fName.Length() - 4);
+ ext = StringTail(fName, 4);
+ name = StringHead(fName, fName.Length() - 4);
}
else
{
ext.Truncate();
name = fName;
}
ToLowerCase(ext);
if (ext.EqualsLiteral(".fol"))
@@ -554,17 +547,17 @@ nsresult nsEudoraWin32::FindTOCFile( nsI
if (NS_FAILED( rv))
return( rv);
rv = pMailFile->GetParent( ppTOCFile);
if (NS_FAILED( rv))
return( rv);
nsCString name;
if ((leaf.Length() > 4) && (leaf.CharAt( leaf.Length() - 4) == '.'))
- leaf.Left( name, leaf.Length() - 4);
+ name = StringHead(leaf, leaf.Length() - 4);
else
name = leaf;
name.Append( ".toc");
rv = (*ppTOCFile)->AppendNative(name);
if (NS_FAILED( rv))
return( rv);
bool exists = false;
@@ -789,37 +782,31 @@ void nsEudoraWin32::GetServerAndUserName
else
{
valSize = ::GetPrivateProfileString( pSection, "POPAccount", "", pBuff, kIniValueSize, pIni);
if (valSize)
{
serverName = pBuff;
idx = serverName.FindChar( '@');
if (idx != -1)
- {
- serverName.Right( tStr, serverName.Length() - idx - 1);
- serverName = tStr;
- }
+ serverName = Substring(serverName, idx + 1);
}
}
valSize = ::GetPrivateProfileString( pSection, "LoginName", "", pBuff, kIniValueSize, pIni);
if (valSize)
userName = pBuff;
else
{
valSize = ::GetPrivateProfileString( pSection, "POPAccount", "", pBuff, kIniValueSize, pIni);
if (valSize)
{
userName = pBuff;
idx = userName.FindChar( '@');
if (idx != -1)
- {
- userName.Left( tStr, idx);
- userName = tStr;
- }
+ userName.SetLength(idx);
}
}
}
void nsEudoraWin32::GetAccountName( const char *pSection, nsString& str)
{
str.Truncate();
@@ -827,27 +814,19 @@ void nsEudoraWin32::GetAccountName( cons
if (s.LowerCaseEqualsLiteral("settings"))
{
str.AssignLiteral("Eudora ");
str.Append(NS_ConvertASCIItoUTF16(pSection));
}
else
{
- nsCString tStr;
- CopyASCIItoUTF16(pSection, str);
- if (s.Length() > 8)
- {
- s.Left( tStr, 8);
- if (tStr.LowerCaseEqualsLiteral("persona-"))
- {
- s.Right( tStr, s.Length() - 8);
- CopyASCIItoUTF16(tStr, str);
- }
- }
+ str.AssignASCII(pSection);
+ if (StringBeginsWith(s, NS_LITERAL_CSTRING("persona-"), nsCaseInsensitiveCStringComparator()))
+ CopyASCIItoUTF16(Substring(s, 8), str);
}
}
bool nsEudoraWin32::BuildPOPAccount( nsIMsgAccountManager *accMgr, const char *pSection, const char *pIni, nsIMsgAccount **ppAccount)
{
if (ppAccount)
*ppAccount = nsnull;
@@ -1108,25 +1087,25 @@ nsresult nsEudoraWin32::GetAttachmentInf
if (name.IsEmpty())
return( NS_ERROR_FAILURE);
if (name.Length() > 4)
{
nsCString ext;
PRInt32 idx = name.RFindChar( '.');
if (idx != -1)
{
- name.Right( ext, name.Length() - idx);
- GetMimeTypeFromExtension( ext, mimeType);
+ ext = Substring(name, idx);
+ GetMimeTypeFromExtension(ext, mimeType);
}
}
if (mimeType.IsEmpty())
mimeType = "application/octet-stream";
nsAutoString description;
- rv = nsMsgI18NConvertToUnicode(nsMsgI18NFileSystemCharset(), name, description);
+ rv = NS_CopyNativeToUnicode(name, description);
if (NS_SUCCEEDED(rv))
aAttachmentName = NS_ConvertUTF16toUTF8(description);
else
aAttachmentName = name;
return( NS_OK);
}
@@ -1163,18 +1142,18 @@ bool nsEudoraWin32::FindMimeIniFile( nsI
if (NS_SUCCEEDED( rv))
{
rv = entry->GetNativeLeafName(fName);
if (NS_SUCCEEDED( rv) && !fName.IsEmpty())
{
if (fName.Length() > 4)
{
- fName.Right( ext, 4);
- fName.Left( name, fName.Length() - 4);
+ ext = StringTail(fName, 4);
+ name = StringHead(fName, fName.Length() - 4);
}
else
{
ext.Truncate();
name = fName;
}
ToLowerCase(ext);
if (ext.EqualsLiteral(".ini"))
@@ -1468,35 +1447,34 @@ nsresult nsEudoraWin32::FindAddressBooks
}
nsCString dirs(pBuffer);
delete [] pBuffer;
dirs.Trim( kWhitespace);
PRInt32 idx = 0;
nsCString currentDir;
while ((idx = dirs.FindChar( ';')) != -1)
{
- dirs.Left( currentDir, idx);
+ currentDir = StringHead(dirs, idx);
currentDir.Trim( kWhitespace);
if (!currentDir.IsEmpty())
{
rv = file->InitWithNativePath(currentDir);
exists = PR_FALSE;
isDir = PR_FALSE;
if (NS_SUCCEEDED( rv))
rv = file->Exists( &exists);
if (NS_SUCCEEDED( rv) && exists)
rv = file->IsDirectory( &isDir);
if (exists && isDir)
{
if (NS_FAILED( rv = ScanAddressDir(file, *ppArray, impSvc)))
return( rv);
}
}
- dirs.Right( currentDir, dirs.Length() - idx - 1);
- dirs = currentDir;
+ dirs = Substring(dirs, idx + 1);
dirs.Trim( kWhitespace);
}
if (!dirs.IsEmpty())
{
rv = file->InitWithNativePath(dirs);
exists = PR_FALSE;
isDir = PR_FALSE;
if (NS_SUCCEEDED( rv))
@@ -1542,18 +1520,18 @@ nsresult nsEudoraWin32::ScanAddressDir(
if (NS_SUCCEEDED( rv))
{
rv = entry->GetNativeLeafName(fName);
if (NS_SUCCEEDED( rv) && !fName.IsEmpty())
{
if (fName.Length() > 4)
{
- fName.Right( ext, 4);
- fName.Left( name, fName.Length() - 4);
+ ext = StringTail(fName, 4);
+ name = StringHead(fName, fName.Length() - 4);
}
else
{
ext.Truncate();
name = fName;
}
ToLowerCase(ext);
if (ext.EqualsLiteral(".txt"))
@@ -1587,22 +1565,19 @@ nsresult nsEudoraWin32::FoundAddressBook
else {
nsAutoString leaf;
rv = file->GetLeafName(leaf);
if (NS_FAILED( rv))
return( rv);
if (leaf.IsEmpty())
return( NS_ERROR_FAILURE);
nsString tStr;
- leaf.Right( tStr, 4);
+ tStr = StringTail(leaf, 4);
if (tStr.LowerCaseEqualsLiteral(".txt") || tStr.LowerCaseEqualsLiteral(".nnt"))
- {
- leaf.Left( tStr, leaf.Length() - 4);
- leaf = tStr;
- }
+ leaf.SetLength(leaf.Length() - 4);
}
nsCOMPtr<nsILocalFile> fileLoc = do_QueryInterface(file, &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = impSvc->CreateNewABDescriptor( getter_AddRefs( desc));
if (NS_SUCCEEDED( rv))
{
@@ -1631,46 +1606,41 @@ void nsEudoraWin32::ConvertPath( nsCStri
nsCString path;
PRInt32 idx = 0;
PRInt32 start = 0;
nsCString search;
idx = str.FindChar( '\\', idx);
if ((idx == 2) && (str.CharAt( 1) == ':'))
{
- str.Left( path, 3);
+ path = StringHead(str, 3);
idx++;
idx = str.FindChar( '\\', idx);
start = 3;
if ((idx == -1) && (str.Length() > 3))
- {
- str.Right( temp, str.Length() - start);
- path.Append( temp);
- }
+ path.Append(Substring(str, start));
}
WIN32_FIND_DATA findFileData;
while (idx != -1)
{
- str.Mid( temp, start, idx - start);
search = path;
- search.Append( temp);
+ search.Append(Substring(str, start, idx - start));
HANDLE h = FindFirstFile( search.get(), &findFileData);
if (h == INVALID_HANDLE_VALUE)
return;
path.Append( findFileData.cFileName);
idx++;
start = idx;
idx = str.FindChar( '\\', idx);
FindClose( h);
if (idx != -1)
path.Append( '\\');
else
{
- str.Right( temp, str.Length() - start);
path.Append( '\\');
- path.Append( temp);
+ path.Append(Substring(str, start));
}
}
str = path;
}
--- a/mailnews/import/eudora/src/nsEudoraWin32.h
+++ b/mailnews/import/eudora/src/nsEudoraWin32.h
@@ -36,17 +36,17 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsEudoraWin32_h__
#define nsEudoraWin32_h__
#include "nscore.h"
-#include "nsString.h"
+#include "nsStringGlue.h"
#include "nsILocalFile.h"
#include "nsISupportsArray.h"
#include "nsEudoraMailbox.h"
#include "nsEudoraAddress.h"
#include <windows.h>
class nsIImportService;
--- a/mailnews/import/oexpress/WabObject.h
+++ b/mailnews/import/oexpress/WabObject.h
@@ -35,17 +35,17 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef WabObject_h___
#define WabObject_h___
#include "nscore.h"
#include "prtypes.h"
-#include "nsString.h"
+#include "nsStringGlue.h"
#include "nsILocalFile.h"
#include <windows.h>
#include <wab.h>
class CWabIterator {
public:
--- a/mailnews/import/oexpress/nsOE5File.h
+++ b/mailnews/import/oexpress/nsOE5File.h
@@ -33,17 +33,17 @@
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsOE5File_h___
#define nsOE5File_h___
-#include "nsString.h"
+#include "nsStringGlue.h"
#include "nsIFile.h"
#include <windows.h>
class nsIInputStream;
class nsOE5File
{
public:
--- a/mailnews/import/oexpress/nsOEAddressIterator.cpp
+++ b/mailnews/import/oexpress/nsOEAddressIterator.cpp
@@ -39,19 +39,19 @@
/*
A sample of XPConnect. This file contains an implementation of
nsISample.
*/
#include "nscore.h"
#include "nsCOMPtr.h"
-#include "nsString.h"
-#include "nsReadableUtils.h"
-#include "nsIComponentManager.h"
+#include "nsStringGlue.h"
+#include "nsMsgUtils.h"
+#include "nsComponentManagerUtils.h"
#include "nsIServiceManager.h"
#include "nsIImportService.h"
#include "nsIImportFieldMap.h"
#include "nsABBaseCID.h"
#include "nsIAbCard.h"
#include "prprf.h"
#include "nsOEAddressIterator.h"
@@ -252,39 +252,34 @@ nsresult nsOEAddressIterator::EnumList(
} while (SUCCEEDED(hr) && cNumRows && lpRowAB);
m_database->SetListAddressTotal(listRow, numListElems);
return rv;
}
void nsOEAddressIterator::SanitizeValue( nsString& val)
{
- val.ReplaceSubstring(NS_LITERAL_STRING("\x0D\x0A").get(),
- NS_LITERAL_STRING(", ").get());
- val.ReplaceChar( 13, ',');
- val.ReplaceChar( 10, ',');
+ MsgReplaceSubstring(val, NS_LITERAL_STRING("\r\n"), NS_LITERAL_STRING(", "));
+ MsgReplaceChar(val, "\r\n", ',');
}
void nsOEAddressIterator::SplitString( nsString& val1, nsString& val2)
{
- nsString temp;
-
// Find the last line if there is more than one!
PRInt32 idx = val1.RFind( "\x0D\x0A");
PRInt32 cnt = 2;
if (idx == -1) {
cnt = 1;
idx = val1.RFindChar( 13);
}
if (idx == -1)
idx= val1.RFindChar( 10);
if (idx != -1) {
- val1.Right( val2, val1.Length() - idx - cnt);
- val1.Left( temp, idx);
- val1 = temp;
+ val2 = Substring(val1, idx + cnt);
+ val1.SetLength(idx);
SanitizeValue( val1);
}
}
void nsOEAddressIterator::SetBirthDay(nsIMdbRow *newRow, PRTime& birthDay)
{
PRExplodedTime exploded;
PR_ExplodeTime(birthDay, PR_LocalTimeParameters, &exploded);
--- a/mailnews/import/oexpress/nsOEImport.cpp
+++ b/mailnews/import/oexpress/nsOEImport.cpp
@@ -43,19 +43,19 @@
*/
#ifdef MOZ_LOGGING
// sorry, this has to be before the pre-compiled header
#define FORCE_PR_LOG /* Allow logging in the release build */
#endif
#include "nscore.h"
-#include "nsString.h"
-#include "nsReadableUtils.h"
-#include "nsIServiceManager.h"
+#include "nsMsgUtils.h"
+#include "nsStringGlue.h"
+#include "nsComponentManagerUtils.h"
#include "nsIImportService.h"
#include "nsOEImport.h"
#include "nsIMemory.h"
#include "nsOEScanBoxes.h"
#include "nsIImportService.h"
#include "nsIImportMail.h"
#include "nsIImportMailboxDescriptor.h"
#include "nsIImportGeneric.h"
--- a/mailnews/import/oexpress/nsOEScanBoxes.cpp
+++ b/mailnews/import/oexpress/nsOEScanBoxes.cpp
@@ -44,17 +44,23 @@
#include "nsOERegUtil.h"
#include "nsOE5File.h"
#include "nsNetUtil.h"
#include "OEDebugLog.h"
#include "nsIInputStream.h"
#include "nsISeekableStream.h"
#include "plstr.h"
+#ifdef MOZILLA_INTERNAL_API
#include "nsNativeCharsetUtils.h"
+#else
+#include "nsMsgI18N.h"
+#define NS_CopyNativeToUnicode(source, dest) \
+ nsMsgI18NConvertToUnicode(nsMsgI18NFileSystemCharset(), source, dest)
+#endif
/*
.nch file format???
offset 20 - long = offset to first record
*/
@@ -243,18 +249,16 @@ bool nsOEScanBoxes::FindMailBoxes( nsIFi
// Now for each record
bool done = false;
PRUint32 equal;
PRUint32 size;
PRUint32 previous;
PRUint32 next;
MailboxEntry * pEntry;
bool failed;
- nsCString ext;
- nsCString mbxExt( ".mbx");
while (!done) {
if (!ReadLong( descInputStream, equal, curRec)) return( PR_FALSE);
if (curRec != equal) {
IMPORT_LOG1( "Record start invalid: %ld\n", curRec);
break;
}
@@ -278,18 +282,17 @@ bool nsOEScanBoxes::FindMailBoxes( nsIFi
#ifdef _TRACE_MAILBOX_ENTRIES
IMPORT_LOG0( "------------\n");
IMPORT_LOG2( " Offset: %lx, index: %ld\n", curRec, pEntry->index);
IMPORT_LOG2( " previous: %lx, next: %lx\n", previous, next);
IMPORT_LOG2( " Name: %S, File: %s\n", (PRUnichar *) pEntry->mailName, (const char *) pEntry->fileName);
IMPORT_LOG3( " Parent: %ld, Child: %ld, Sibling: %ld\n", pEntry->parent, pEntry->child, pEntry->sibling);
#endif
- pEntry->fileName.Right( ext, 4);
- if (!ext.Equals(mbxExt))
+ if (!StringEndsWith(pEntry->fileName, NS_LITERAL_CSTRING(".mbx")))
pEntry->fileName.Append( ".mbx");
m_entryArray.AppendElement( pEntry);
curRec = next;
if (!next)
done = PR_TRUE;
}
@@ -870,17 +873,17 @@ bool nsOEScanBoxes::ReadString( nsIInput
PRUint32 cntRead;
char buffer[kOutlookExpressStringLength];
char * pReadTo = buffer;
rv = stream->Read( pReadTo, kOutlookExpressStringLength, &cntRead);
if (NS_FAILED( rv) || (cntRead != kOutlookExpressStringLength))
return( PR_FALSE);
buffer[kOutlookExpressStringLength - 1] = 0;
- CopyASCIItoUTF16(buffer, str);
+ str.AssignASCII(buffer);
return( PR_TRUE);
}
bool nsOEScanBoxes::ReadString( nsIInputStream * stream, nsCString& str, PRUint32 offset)
{
nsresult rv;
nsCOMPtr <nsISeekableStream> seekStream = do_QueryInterface(stream, &rv);
NS_ENSURE_SUCCESS(rv, PR_FALSE);
--- a/mailnews/import/outlook/src/MapiApi.cpp
+++ b/mailnews/import/outlook/src/MapiApi.cpp
@@ -189,17 +189,17 @@ BOOL CMapiApi::GetRTFPropertyDecodedAsUT
nativeBodyType = MAPI_NATIVE_BODY_TYPE_HTML;
else if (decoder.mode() == CRTFMailDecoder::mText)
nativeBodyType = MAPI_NATIVE_BODY_TYPE_PLAINTEXT;
else
nativeBodyType = MAPI_NATIVE_BODY_TYPE_RTF;
val.Assign(decoder.text(), decoder.textSize());
}
else { // WrapCompressedRTFStreamEx available and original type is not rtf
- CopyUTF8toUTF16(streamData.c_str(), val);
+ CopyUTF8toUTF16(nsDependentCString(streamData.c_str()), val);
}
return TRUE;
}
return FALSE;
}
void CMapiApi::MAPIUninitialize(void)
{
@@ -1268,17 +1268,17 @@ BOOL CMapiApi::GetLargeProperty( LPMAPIP
}
BOOL CMapiApi::GetLargeStringProperty( LPMAPIPROP pProp, ULONG tag, nsCString& val)
{
void* result;
if (!GetLargeProperty(pProp, tag, &result))
return FALSE;
if (PROP_TYPE(tag) == PT_UNICODE) // unicode string
- LossyCopyUTF16toASCII(static_cast<wchar_t*>(result), val);
+ LossyCopyUTF16toASCII(nsDependentString(static_cast<wchar_t*>(result)), val);
else // either PT_STRING8 or some other binary - use as is
val.Assign(static_cast<char*>(result));
delete[] result;
return TRUE;
}
BOOL CMapiApi::GetLargeStringProperty(LPMAPIPROP pProp, ULONG tag, nsString& val)
{
@@ -1320,17 +1320,17 @@ BOOL CMapiApi::GetEntryIdFromProp(LPSPro
}
BOOL CMapiApi::GetStringFromProp( LPSPropValue pVal, nsCString& val, BOOL delVal)
{
BOOL bResult = TRUE;
if ( pVal && (PROP_TYPE( pVal->ulPropTag) == PT_STRING8))
val = pVal->Value.lpszA;
else if ( pVal && (PROP_TYPE( pVal->ulPropTag) == PT_UNICODE))
- LossyCopyUTF16toASCII((PRUnichar *) pVal->Value.lpszW, val);
+ LossyCopyUTF16toASCII(nsDependentString(pVal->Value.lpszW), val);
else if (pVal && (PROP_TYPE( pVal->ulPropTag) == PT_NULL))
val.Truncate();
else if (pVal && (PROP_TYPE( pVal->ulPropTag) == PT_ERROR)) {
val.Truncate();
bResult = FALSE;
}
else {
if (pVal) {
@@ -1517,54 +1517,31 @@ void CMapiApi::GetPropTagName( ULONG tag
case PT_MV_UNICODE: s += "PT_MV_UNICODE"; break;
case PT_MV_CLSID: s += "PT_MV_CLSID"; break;
case PT_MV_I8: s += "PT_MV_I8"; break;
default:
s += "Unknown";
}
}
-void ReplaceEolChars( nsCString& s)
-{
- int idx;
- nsCString t;
- nsCString rt;
-
- while ((idx = s.Find( "\x0D")) != -1) {
- s.Left( t, idx);
- t += "\\n";
- s.Right( rt, s.Length() - idx - 1);
- t += rt;
- s = t;
- }
- while ((idx = s.Find( "\x0A")) != -1) {
- s.Left( t, idx);
- t += "\\r";
- s.Right( rt, s.Length() - idx - 1);
- t += rt;
- s = t;
- }
-}
-
void CMapiApi::ListPropertyValue( LPSPropValue pVal, nsCString& s)
{
nsCString strVal;
char nBuff[64];
- nsCString t;
s += "value: ";
switch (PROP_TYPE( pVal->ulPropTag)) {
case PT_STRING8:
GetStringFromProp( pVal, strVal, FALSE);
if (strVal.Length() > 60) {
- strVal.Left( t, 60);
- strVal = t;
+ strVal.SetLength(60);
strVal += "...";
}
- ReplaceEolChars( strVal);
+ MsgReplaceSubstring(strVal, "\r", "\\r");
+ MsgReplaceSubstring(strVal, "\n", "\\n");
s += strVal;
break;
case PT_LONG:
s.AppendInt( (PRInt32) pVal->Value.l);
s += ", 0x";
s.AppendInt( (PRInt32) pVal->Value.l, 16);
s += nBuff;
break;
--- a/mailnews/import/outlook/src/MapiMessage.cpp
+++ b/mailnews/import/outlook/src/MapiMessage.cpp
@@ -281,17 +281,17 @@ bool CMapiMessage::FetchHeaders( void)
m_headers.Assign(headers.get());
}
else if ((PROP_TYPE(pVal->ulPropTag) == PT_STRING8) &&
(pVal->Value.lpszA) && (*(pVal->Value.lpszA)))
m_headers.Assign(pVal->Value.lpszA);
else if ((PROP_TYPE(pVal->ulPropTag) == PT_UNICODE) &&
(pVal->Value.lpszW) && (*(pVal->Value.lpszW))) {
nsCString headers;
- LossyCopyUTF16toASCII(pVal->Value.lpszW, headers);
+ LossyCopyUTF16toASCII(nsDependentString(pVal->Value.lpszW), headers);
m_headers.Assign(headers.get());
}
CMapiApi::MAPIFreeBuffer(pVal);
}
EnsureDate();
if (!EnsureHeader(CMapiMessageHeaders::hdrFrom, PR_SENDER_NAME_W))
@@ -301,25 +301,16 @@ bool CMapiMessage::FetchHeaders( void)
EnsureHeader(CMapiMessageHeaders::hdrCc, PR_DISPLAY_CC_W);
EnsureHeader(CMapiMessageHeaders::hdrBcc, PR_DISPLAY_BCC_W);
ProcessContentType();
return( !m_headers.IsEmpty());
}
-bool CMapiMessage::IsMultipart( void) const
-{
- nsCString left;
- m_mimeContentType.Left( left, 10);
- if (left.LowerCaseEqualsLiteral("multipart/"))
- return true;
- return false;
-}
-
// Mime-Version: 1.0
// Content-Type: text/plain; charset="US-ASCII"
// Content-Type: multipart/mixed; boundary="=====================_874475278==_"
void CMapiMessage::ProcessContentType()
{
m_mimeContentType.Truncate();
m_mimeBoundary.Truncate();
@@ -727,17 +718,17 @@ bool CMapiMessage::FetchBody( void)
// We'll use this as a hack to really use the plain text part.
//
// Sadly there are cases where this string is returned despite the fact
// that the message is indeed HTML.
//
// To detect the "true" plain text messages, we look for our string
// immediately following the <BODY> tag.
if (!m_body.IsEmpty() &&
- m_body.Find(L"<BODY>\r\n<!-- Converted from text/plain format -->") ==
+ m_body.Find("<BODY>\r\n<!-- Converted from text/plain format -->") ==
kNotFound) {
m_bodyIsHtml = true;
}
else {
pVal = CMapiApi::GetMapiProperty(m_lpMsg, PR_BODY_W);
if (pVal) {
if (CMapiApi::IsLargeProperty(pVal))
CMapiApi::GetLargeStringProperty(m_lpMsg, PR_BODY_W, m_body);
@@ -1072,17 +1063,17 @@ bool CMapiMessage::AddAttachment(DWORD a
pVal = CMapiApi::GetMapiProperty(lpAttach, PR_ATTACH_EXTENSION_W);
CMapiApi::GetStringFromProp(pVal, fext);
MAPI_TRACE2("\t\t\t--- File name: %s, extension: %s\r\n",
fname.get(), fext.get());
if (fext.IsEmpty()) {
int idx = fname.RFindChar(L'.');
if (idx != -1)
- fname.Right(fext, fname.Length() - idx);
+ fext = Substring(fname, idx);
}
else if (fname.RFindChar(L'.') == -1) {
fname += L".";
fname += fext;
}
if (fname.IsEmpty()) {
// If no description use "Attachment i" format.
fname = L"Attachment ";
--- a/mailnews/import/outlook/src/MapiMessage.h
+++ b/mailnews/import/outlook/src/MapiMessage.h
@@ -212,17 +212,16 @@ public:
inline const char *GetBodyCharset( void) const { return( m_mimeCharset.get());}
inline bool IsRead() const { return m_msgFlags & MSGFLAG_READ; }
inline bool IsReplied() const {
return (m_msgLastVerb == EXCHIVERB_REPLYTOSENDER) ||
(m_msgLastVerb == EXCHIVERB_REPLYTOALL); }
inline bool IsForvarded() const {
return m_msgLastVerb == EXCHIVERB_FORWARD; }
- bool IsMultipart( void) const;
bool HasContentHeader( void) const {
return( !m_mimeContentType.IsEmpty());}
bool HasMimeVersion( void) const {
return m_headers.Value(CMapiMessageHeaders::hdrMimeVersion); }
const char *GetMimeContent( void) const { return( m_mimeContentType.get());}
PRInt32 GetMimeContentLen( void) const { return( m_mimeContentType.Length());}
const char *GetMimeBoundary( void) const { return( m_mimeBoundary.get());}
--- a/mailnews/import/outlook/src/nsOutlookCompose.cpp
+++ b/mailnews/import/outlook/src/nsOutlookCompose.cpp
@@ -43,17 +43,16 @@
#include "nsUnicharUtils.h"
#include "nsCOMPtr.h"
#include "nsIFile.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsIIOService.h"
#include "nsIURI.h"
#include "nsMsgI18N.h"
-#include "nsNativeCharsetUtils.h"
#include "nsIOutputStream.h"
#include "nsMsgBaseCID.h"
#include "nsMsgCompCID.h"
#include "nsIArray.h"
#include "nsIMsgCompose.h"
#include "nsIMsgCompFields.h"
#include "nsIMsgAccountManager.h"
@@ -429,24 +428,24 @@ nsresult nsOutlookCompose::ComposeTheMes
return rv;
}
nsOutlookCompose::ReplaceCidInLine::ReplaceCidInLine(nsCString& line)
: m_line(line)
{
// If the line begins with Content-ID: string, process it! Otherwise, no need to waste time
- m_finishedReplacing = (line.Compare("Content-ID:", PR_TRUE, 11) != 0);
+ m_finishedReplacing = StringBeginsWith(line, NS_LITERAL_CSTRING("Content-ID:"), nsCaseInsensitiveCStringComparator());
}
void nsOutlookCompose::ReplaceCidInLine::operator () (const CidReplacePair* pair)
{
if (m_finishedReplacing)
return; // Only one cid per line possible!
- PRInt32 pos = m_line.Find(pair->cidNew, PR_FALSE, 12);
+ PRInt32 pos = MsgFind(m_line, pair->cidNew, false, 12);
if (pos != kNotFound) {
m_finishedReplacing = true; // Stop further search
m_line.Replace(pos, pair->cidNew.Length(), pair->cidOrig);
}
}
nsresult nsOutlookCompose::CopyComposedMessage(nsIFile *pSrc,
nsIOutputStream *pDst,
@@ -634,17 +633,19 @@ void nsOutlookCompose::UpdateHeaders(CMa
// applies to html &#XXXX; (where XXXX is unicode codepoint).
// See also Bug 503690, where the same issue in Eudora import is reported.
// By the way, the root of the Bug 359303 lies in the same place - the nsMsgComposeAndSend::GetBodyFromEditor()
// changes the 0xA0 codes to 0x20 when it converts the body to plain text.
// We scan the body here to find all the & and convert them to the safe character sequense to revert later.
void nsOutlookCompose::HackBody(const wchar_t* orig, size_t origLen, nsString& hack)
{
+#ifdef MOZILLA_INTERNAL_API
hack.SetCapacity(static_cast<size_t>(origLen*1.4));
+#endif
hack.Assign(hackBeginW);
hack.Append(m_hackedPostfix);
while (*orig) {
if (*orig == L'&') {
hack.Append(hackAmpersandW);
hack.Append(m_hackedPostfix);
} else if ((*orig == L'\x0D') && (*(orig+1) == L'\x0A')) {
@@ -669,60 +670,36 @@ void nsOutlookCompose::UnhackBody(nsCStr
hackedString.Append(hackedPostfixA);
PRInt32 begin = txt.Find(hackedString);
if (begin == kNotFound)
return;
txt.Cut(begin, hackedString.Length());
hackedString.Assign(hackEndA);
hackedString.Append(hackedPostfixA);
- PRInt32 end = txt.Find(hackedString, PR_FALSE, begin);
+ PRInt32 end = MsgFind(txt, hackedString, PR_FALSE, begin);
if (end == kNotFound)
return; // ?
txt.Cut(end, hackedString.Length());
+ nsCString range;
+ range.Assign(Substring(txt, begin, end - begin));
// 1. Remove all CRLFs from the selected range
- PRInt32 i = begin;
- while (i < end) {
- PRInt32 r = txt.Find(MSG_LINEBREAK, PR_FALSE, i, end-i);
- if (r == kNotFound)
- break;
-
- txt.Cut(r, 2);
- end -= 2;
- i = r;
- }
-
+ MsgReplaceSubstring(range, MSG_LINEBREAK, "");
// 2. Restore the original CRLFs
hackedString.Assign(hackCRLFA);
hackedString.Append(hackedPostfixA);
- i = begin;
- while (i < end) {
- PRInt32 r = txt.Find(hackedString, PR_FALSE, i, end-i);
- if (r == kNotFound)
- break;
-
- txt.Replace(r, hackedString.Length(), MSG_LINEBREAK, 2);
- end -= hackedString.Length()-2;
- i = r+2;
- }
+ MsgReplaceSubstring(range, hackedString.get(), MSG_LINEBREAK);
// 3. Restore the original ampersands
hackedString.Assign(hackAmpersandA);
hackedString.Append(hackedPostfixA);
- i = begin;
- while (i < end) {
- PRInt32 r = txt.Find(hackedString, PR_FALSE, i, end-i);
- if (r == kNotFound)
- break;
+ MsgReplaceSubstring(range, hackedString.get(), "&");
- txt.Replace(r, hackedString.Length(), '&');
- end -= hackedString.Length()-1;
- i = r+1;
- }
+ txt.Replace(begin, end - begin, range);
}
bool nsOutlookCompose::GenerateHackSequence(const wchar_t* body, size_t origLen)
{
nsDependentString nsBody(body, origLen);
const wchar_t* hack_base = L"hacked";
int i = 0;
do {
@@ -822,19 +799,21 @@ private:
int m_matchPos;
};
template <class _OutFn>
nsresult CCompositionFile::ToDest(_OutFn dest, const char* term, int termSize)
{
CTermGuard guard(term, termSize);
+#ifdef MOZILLA_INTERNAL_API
// We already know the required string size, so reduce future reallocations
if (!guard.IsChecking() && !m_convertCRs)
dest.SetCapacity(m_fileSize - m_fileReadPos);
+#endif
bool wasCR = false;
char c = 0;
nsresult rv;
while (NS_SUCCEEDED(rv = EnsureHasDataInBuffer())) {
if (!guard.IsChecking() && !m_convertCRs) { // Use efficient algorithm
dest.Append(m_fifoBufferReadPos, m_fifoBufferWrittenPos-m_fifoBufferReadPos);
}
@@ -876,27 +855,31 @@ nsresult CCompositionFile::ToDest(_OutFn
m_lastChar = c;
return NS_OK;
}
class dest_nsCString {
public:
dest_nsCString(nsCString& str) : m_str(str) { m_str.Truncate(); }
+#ifdef MOZILLA_INTERNAL_API
void SetCapacity(PRInt32 sz) { m_str.SetCapacity(sz); }
+#endif
nsresult Append(const char* buf, PRUint32 count) {
m_str.Append(buf, count); return NS_OK; }
private:
nsCString& m_str;
};
class dest_Stream {
public:
dest_Stream(nsIOutputStream *dest) : m_stream(dest) {}
+#ifdef MOZILLA_INTERNAL_API
void SetCapacity(PRInt32) { /*do nothing*/ }
+#endif
// const_cast here is due to the poor design of the EscapeFromSpaceLine()
// that requires a non-constant pointer while doesn't modify its data
nsresult Append(const char* buf, PRUint32 count) {
return EscapeFromSpaceLine(m_stream, const_cast<char*>(buf), buf+count); }
private:
nsIOutputStream *m_stream;
};
--- a/mailnews/import/outlook/src/nsOutlookEditor.cpp
+++ b/mailnews/import/outlook/src/nsOutlookEditor.cpp
@@ -33,20 +33,20 @@
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsOutlookEditor.h"
-#include "nsISupportsArray.h"
+#include "nsMsgUtils.h"
#include "nsIDOMHTMLImageElement.h"
#include "nsComponentManagerUtils.h"
-#include "nsString.h"
+#include "nsStringGlue.h"
#include "nsNetUtil.h"
NS_IMPL_ISUPPORTS2(nsOutlookEditor, nsIEditor, nsIEditorMailSupport)
NS_IMPL_THREADSAFE_ISUPPORTS5(nsOutlookHTMLImageElement,
nsOutlookHTMLImageElement,
nsIDOMHTMLImageElement,
nsIDOMHTMLElement,
nsIDOMElement,
@@ -632,18 +632,18 @@ nsresult nsOutlookEditor::GetCids(PRUint
if (!m_EmbeddedObjectList)
return NS_ERROR_FAILURE;
nsCOMPtr<nsOutlookHTMLImageElement> node;
nsresult rv = m_EmbeddedObjectList->QueryElementAt(
embedIndex, NS_GET_IID(nsOutlookHTMLImageElement), getter_AddRefs(node));
if (node) {
if (!node->NewCid())
return NS_ERROR_FAILURE; // no need to replace anything!
- LossyCopyUTF16toASCII(node->OrigCid(), origCid);
- LossyCopyUTF16toASCII(node->NewCid(), newCid);
+ LossyCopyUTF16toASCII(nsDependentString(node->OrigCid()), origCid);
+ LossyCopyUTF16toASCII(nsDependentString(node->NewCid()), newCid);
}
return rv;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
nsOutlookHTMLImageElement::nsOutlookHTMLImageElement
(nsOutlookEditor *pEditor, nsIURI *uri, const wchar_t *cid, const wchar_t *name)
@@ -1327,17 +1327,17 @@ NS_IMETHODIMP nsOutlookHTMLImageElement:
NS_IMETHODIMP nsOutlookHTMLImageElement::SetSrc(const nsAString & aSrc)
{
// nsEudoraHTMLImageElement calls UpdateEmbeddedImageReference(m_cid, aSrc)
// on the editor here, but our editor doen't implement it.
// The nsMsgNend::ProcessMultipartRelated seems to call SetSrc twice.
// I'm not sure if I need to do it second time.
if (m_cid_new.IsEmpty())
- m_cid_new.Assign(aSrc.Data()+4, aSrc.Length()-4); // strip the "cid:"
+ m_cid_new.Assign(Substring(aSrc, 4)); // strip the "cid:"
return NS_OK;
}
// attribute DOMString useMap
NS_IMETHODIMP nsOutlookHTMLImageElement::GetUseMap(nsAString & aUseMap)
{
return NS_ERROR_NOT_IMPLEMENTED;
--- a/mailnews/import/outlook/src/nsOutlookEditor.h
+++ b/mailnews/import/outlook/src/nsOutlookEditor.h
@@ -36,17 +36,17 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nscore.h"
#include "nsIEditor.h"
#include "nsIEditorMailSupport.h"
#include "nsIDOMHTMLImageElement.h"
#include "nsCOMPtr.h"
-#include "nsString.h"
+#include "nsStringGlue.h"
#include "nsIFile.h"
class nsOutlookEditor : public nsIEditor, public nsIEditorMailSupport
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIEDITOR
NS_DECL_NSIEDITORMAILSUPPORT
--- a/mailnews/import/outlook/src/nsOutlookMail.cpp
+++ b/mailnews/import/outlook/src/nsOutlookMail.cpp
@@ -50,17 +50,16 @@
#include "nsIImportABDescriptor.h"
#include "nsOutlookStringBundle.h"
#include "nsABBaseCID.h"
#include "nsIAbCard.h"
#include "mdb.h"
#include "OutlookDebugLog.h"
#include "nsOutlookMail.h"
#include "nsUnicharUtils.h"
-#include "nsMsgUtils.h"
#include "nsIOutputStream.h"
#include "nsMsgI18N.h"
#include "nsNetUtil.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
/* ------------ Address book stuff ----------------- */
typedef struct {
@@ -618,17 +617,17 @@ nsresult nsOutlookMail::CreateList( cons
// Make sure we have db to work with.
if (!pDb)
return rv;
nsCOMPtr <nsIMdbRow> newListRow;
rv = pDb->GetNewListRow(getter_AddRefs(newListRow));
NS_ENSURE_SUCCESS(rv, rv);
nsCAutoString column;
- LossyCopyUTF16toASCII(pName, column );
+ LossyCopyUTF16toASCII(nsDependentString(pName), column);
rv = pDb->AddListName(newListRow, column.get());
NS_ENSURE_SUCCESS(rv, rv);
HRESULT hr;
LPSPropValue value = NULL;
ULONG valueCount = 0;
LPSPropTagArray properties = NULL;
@@ -716,39 +715,34 @@ nsresult nsOutlookMail::CreateList( cons
rv = pDb->SetListAddressTotal(newListRow, total);
rv = pDb->AddListDirNode(newListRow);
return rv;
}
void nsOutlookMail::SanitizeValue( nsString& val)
{
- val.ReplaceSubstring(NS_LITERAL_STRING("\x0D\x0A").get(),
- NS_LITERAL_STRING(", ").get());
- val.ReplaceChar( 13, ',');
- val.ReplaceChar( 10, ',');
+ MsgReplaceSubstring(val, NS_LITERAL_STRING("\r\n"), NS_LITERAL_STRING(", "));
+ MsgReplaceChar(val, "\r\n", ',');
}
void nsOutlookMail::SplitString( nsString& val1, nsString& val2)
{
- nsString temp;
-
// Find the last line if there is more than one!
PRInt32 idx = val1.RFind( "\x0D\x0A");
PRInt32 cnt = 2;
if (idx == -1) {
cnt = 1;
idx = val1.RFindChar( 13);
}
if (idx == -1)
idx= val1.RFindChar( 10);
if (idx != -1) {
- val1.Right( val2, val1.Length() - idx - cnt);
- val1.Left( temp, idx);
- val1 = temp;
+ val2 = Substring(val1, idx + cnt);
+ val1.SetLength(idx);
SanitizeValue( val1);
}
}
bool nsOutlookMail::BuildCard( const PRUnichar *pName, nsIAddrDatabase *pDb, nsIMdbRow *newRow, LPMAPIPROP pUser, nsIImportFieldMap *pFieldMap)
{
nsString lastName;
--- a/mailnews/import/text/src/nsTextAddress.cpp
+++ b/mailnews/import/text/src/nsTextAddress.cpp
@@ -44,16 +44,22 @@
#include "nsIInputStream.h"
#include "nsILineInputStream.h"
#include "nsNetUtil.h"
#include "TextDebugLog.h"
#include "plstr.h"
#include "msgCore.h"
+#ifndef MOZILLA_INTERNAL_API
+#include "nsMsgI18N.h"
+#define NS_CopyNativeToUnicode(source, dest) \
+ nsMsgI18NConvertToUnicode(nsMsgI18NFileSystemCharset(), source, dest)
+#endif
+
#define kWhitespace " \t\b\r\n"
// If we get a line longer than 32K it's just toooooo bad!
#define kTextAddressBufferSz (64 * 1024)
nsTextAddress::nsTextAddress()
{
m_database = nsnull;
--- a/mailnews/import/text/src/nsTextImport.cpp
+++ b/mailnews/import/text/src/nsTextImport.cpp
@@ -67,17 +67,17 @@
#include "nsAbBaseCID.h"
#include "nsTextFormatter.h"
#include "nsImportStringBundle.h"
#include "nsTextAddress.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "TextDebugLog.h"
#include "nsNetUtil.h"
-#include "nsISupportsArray.h"
+#include "nsMsgUtils.h"
#define TEXT_MSGS_URL "chrome://messenger/locale/textImportMsgs.properties"
#define TEXTIMPORT_NAME 2000
#define TEXTIMPORT_DESCRIPTION 2001
#define TEXTIMPORT_ADDRESS_NAME 2002
#define TEXTIMPORT_ADDRESS_SUCCESS 2003
#define TEXTIMPORT_ADDRESS_BADPARAM 2004
#define TEXTIMPORT_ADDRESS_BADSOURCEFILE 2005
--- a/mailnews/import/vcard/src/nsVCardImport.cpp
+++ b/mailnews/import/vcard/src/nsVCardImport.cpp
@@ -48,17 +48,18 @@
#include "nsIImportABDescriptor.h"
#include "nsIImportAddressBooks.h"
#include "nsIImportFieldMap.h"
#include "nsIImportGeneric.h"
#include "nsCOMPtr.h"
#include "nsIImportService.h"
#include "nsILocalFile.h"
#include "nsImportStringBundle.h"
-#include "nsISupportsArray.h"
+#include "nsMsgUtils.h"
+#include "nsComponentManagerUtils.h"
#include "nsServiceManagerUtils.h"
#include "nsTextFormatter.h"
#include "nsVCardAddress.h"
#include "nsVCardImport.h"
PRLogModuleInfo *VCARDLOGMODULE = nsnull;
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);