--- a/mailnews/import/applemail/src/nsAppleMailImport.cpp
+++ b/mailnews/import/applemail/src/nsAppleMailImport.cpp
@@ -43,18 +43,16 @@
#include "nsStringGlue.h"
#include "nsCOMPtr.h"
#include "nsISupportsPrimitives.h"
#include "nsIImportService.h"
#include "nsIImportMailboxDescriptor.h"
#include "nsIImportGeneric.h"
#include "nsILocalFile.h"
#include "nsIStringBundle.h"
-#include "nsIProxyObjectManager.h"
-#include "nsXPCOMCIDInternal.h"
#include "nsNetUtil.h"
#include "nsMsgUtils.h"
#include "nsEmlxHelperUtils.h"
#include "nsAppleMailImport.h"
PRLogModuleInfo *APPLEMAILLOGMODULE = nsnull;
@@ -168,28 +166,17 @@ nsAppleMailImportMail::nsAppleMailImport
}
nsresult nsAppleMailImportMail::Initialize()
{
nsresult rv;
nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
- nsCOMPtr<nsIStringBundle> bundle;
- rv = bundleService->CreateBundle(APPLEMAIL_MSGS_URL, getter_AddRefs(bundle));
- NS_ENSURE_SUCCESS(rv, rv);
-
- nsCOMPtr<nsIProxyObjectManager> proxyObjectManager =
- do_GetService(NS_XPCOMPROXY_CONTRACTID, &rv);
- NS_ENSURE_SUCCESS(rv, rv);
-
- return proxyObjectManager->GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
- NS_GET_IID(nsIStringBundle),
- bundle, NS_PROXY_SYNC | NS_PROXY_ALWAYS,
- getter_AddRefs(mBundleProxy));
+ return bundleService->CreateBundle(APPLEMAIL_MSGS_URL, getter_AddRefs(mBundle));
}
nsAppleMailImportMail::~nsAppleMailImportMail()
{
IMPORT_LOG0("nsAppleMailImportMail destroyed");
}
NS_IMPL_THREADSAFE_ISUPPORTS1(nsAppleMailImportMail, nsIImportMail)
@@ -619,17 +606,17 @@ NS_IMETHODIMP nsAppleMailImportMail::Imp
return NS_OK;
}
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 = mBundleProxy->FormatStringFromID(aErrorNum, &fmt, 1, getter_Copies(outString));
+ 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"));
}
void nsAppleMailImportMail::SetLogs(const nsAString &aSuccess, const nsAString &aError, PRUnichar **aOutSuccess, PRUnichar **aOutError)
{
if (aOutError && !*aOutError)
--- a/mailnews/import/applemail/src/nsAppleMailImport.h
+++ b/mailnews/import/applemail/src/nsAppleMailImport.h
@@ -78,33 +78,33 @@ class nsAppleMailImportModule : public n
private:
nsCOMPtr<nsIStringBundle> mBundle;
};
class nsAppleMailImportMail : public nsIImportMail
{
public:
-
+
nsAppleMailImportMail();
virtual ~nsAppleMailImportMail();
NS_DECL_ISUPPORTS
NS_DECL_NSIIMPORTMAIL
nsresult Initialize();
private:
-
+
void FindAccountMailDirs(nsIFile *aRoot, nsISupportsArray *aMailboxDescs, nsIImportService *aImportService);
nsresult FindMboxDirs(nsILocalFile *aFolder, nsISupportsArray *aMailboxDescs, nsIImportService *aImportService);
nsresult AddMboxDir(nsILocalFile *aFolder, nsISupportsArray *aMailboxDescs, nsIImportService *aImportService);
// aInfoString is the format to a "foo %s" string. It may be NULL if the error string needs no such format.
void ReportStatus(PRInt32 aErrorNum, nsString &aName, nsAString &aStream);
static void SetLogs(const nsAString& success, const nsAString& error, PRUnichar **aOutErrorLog, PRUnichar **aSuccessLog);
-
- nsCOMPtr<nsIStringBundle> mBundleProxy;
+
+ nsCOMPtr<nsIStringBundle> mBundle;
PRUint32 mProgress;
PRUint16 mCurDepth;
};
#endif /* nsAppleMailImport_h___ */
--- a/mailnews/import/comm4x/src/nsComm4xMailImport.cpp
+++ b/mailnews/import/comm4x/src/nsComm4xMailImport.cpp
@@ -63,18 +63,16 @@
#include "nsIOutputStream.h"
#include "nsTextFormatter.h"
#include "nsComm4xMailStringBundle.h"
#include "nsIStringBundle.h"
#include "Comm4xMailDebugLog.h"
#include "nsServiceManagerUtils.h"
#include "nsDirectoryServiceDefs.h"
#include "nsComponentManagerUtils.h"
-#include "nsIProxyObjectManager.h"
-#include "nsXPCOMCIDInternal.h"
#define COMM4XMAIL_MSGS_URL "chrome://messenger/locale/comm4xMailImportMsgs.properties"
PRLogModuleInfo *COMM4XLOGMODULE = nsnull;
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
@@ -177,41 +175,26 @@ NS_IMETHODIMP nsComm4xMailImport::GetImp
return NS_ERROR_NOT_AVAILABLE;
}
/////////////////////////////////////////////////////////////////////////////////
ImportComm4xMailImpl::ImportComm4xMailImpl()
{
- m_pBundleProxy = nsnull;
}
nsresult ImportComm4xMailImpl::Initialize()
{
- nsCOMPtr <nsIStringBundleService> pBundleService;
- nsresult rv;
- nsCOMPtr <nsIStringBundle> pBundle;
-
- pBundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
- if (NS_SUCCEEDED(rv) && (pBundleService)) {
- pBundleService->CreateBundle(COMM4XMAIL_MSGS_URL, getter_AddRefs(pBundle));
+ nsCOMPtr<nsIStringBundleService> pBundleService;
+ nsresult rv;
- nsCOMPtr<nsIProxyObjectManager> proxyObjectManager =
- do_GetService(NS_XPCOMPROXY_CONTRACTID, &rv);
- if (NS_FAILED(rv))
- return nsnull;
-
- rv = proxyObjectManager->GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
- NS_GET_IID(nsIStringBundle),
- pBundle,
- NS_PROXY_SYNC | NS_PROXY_ALWAYS,
- getter_AddRefs(m_pBundleProxy));
- }
- return rv;
+ pBundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
+ NS_ENSURE_SUCCESS(rv, rv);
+ return pBundleService->CreateBundle(COMM4XMAIL_MSGS_URL, getter_AddRefs(m_pBundle));
}
ImportComm4xMailImpl::~ImportComm4xMailImpl()
{
}
@@ -251,17 +234,17 @@ NS_IMETHODIMP ImportComm4xMailImpl::Find
return rv;
}
void ImportComm4xMailImpl::ReportStatus( PRInt32 errorNum, nsString& name, nsString *pStream)
{
if (!pStream) return;
nsString statusStr;
const PRUnichar * fmtStr = name.get();
- nsresult rv = m_pBundleProxy->FormatStringFromID(errorNum, &fmtStr, 1, getter_Copies(statusStr));
+ nsresult rv = m_pBundle->FormatStringFromID(errorNum, &fmtStr, 1, getter_Copies(statusStr));
if (NS_SUCCEEDED (rv)) {
pStream->Append (statusStr.get());
pStream->Append( PRUnichar('\n'));
}
}
void ImportComm4xMailImpl::SetLogs(nsString& success, nsString& error, PRUnichar **pError, PRUnichar **pSuccess)
@@ -281,17 +264,17 @@ NS_IMETHODIMP ImportComm4xMailImpl::Impo
NS_PRECONDITION(pSource != nsnull, "null ptr");
NS_PRECONDITION(pDestination != nsnull, "null ptr");
NS_PRECONDITION(fatalError != nsnull, "null ptr");
nsString success;
nsString error;
if (!pSource || !pDestination || !fatalError) {
nsString errorString;
- m_pBundleProxy->GetStringFromID(COMM4XMAILIMPORT_MAILBOX_BADPARAM, getter_Copies(errorString));
+ m_pBundle->GetStringFromID(COMM4XMAILIMPORT_MAILBOX_BADPARAM, getter_Copies(errorString));
error = errorString;
if (fatalError)
*fatalError = PR_TRUE;
SetLogs(success, error, pErrorLog, pSuccessLog);
return NS_ERROR_NULL_POINTER;
}
nsString name;
--- a/mailnews/import/comm4x/src/nsComm4xMailImport.h
+++ b/mailnews/import/comm4x/src/nsComm4xMailImport.h
@@ -67,17 +67,17 @@ public:
////////////////////////////////////////////////////////////////////////////////////////
// we suppport the nsIImportModule interface
////////////////////////////////////////////////////////////////////////////////////////
NS_DECL_NSIIMPORTMODULE
protected:
- nsCOMPtr <nsIStringBundle> m_pBundle;
+ nsCOMPtr<nsIStringBundle> m_pBundle;
};
class ImportComm4xMailImpl : public nsIImportMail
{
public:
ImportComm4xMailImpl();
virtual ~ImportComm4xMailImpl();
@@ -104,13 +104,13 @@ public:
public:
static void SetLogs(nsString& success, nsString& error, PRUnichar **pError, PRUnichar **pSuccess);
void ReportStatus(PRInt32 errorNum, nsString& name, nsString *pStream);
nsresult Initialize();
private:
nsComm4xMail m_mail;
PRUint32 m_bytesDone;
- nsCOMPtr<nsIStringBundle> m_pBundleProxy;
+ nsCOMPtr<nsIStringBundle> m_pBundle;
};
#endif /* nsComm4xMailImport_h___ */
--- a/mailnews/import/eudora/src/nsEudoraAddress.cpp
+++ b/mailnews/import/eudora/src/nsEudoraAddress.cpp
@@ -750,20 +750,20 @@ void nsEudoraAddress::ExtractNoteField(
note.Left( tempL, idx);
nsCString tempR;
note.Right( tempR, note.Length() - endIdx - 1);
note = tempL;
note.Append( tempR);
}
}
-void nsEudoraAddress::FormatExtraDataInNoteField(PRInt32 labelStringID, nsIStringBundle* bundle, nsCString& extraData, nsString& noteUTF16)
+void nsEudoraAddress::FormatExtraDataInNoteField(PRInt32 labelStringID, nsCString& extraData, nsString& noteUTF16)
{
nsAutoString label;
- nsEudoraStringBundle::GetStringByID(labelStringID, label, bundle);
+ nsEudoraStringBundle::GetStringByID(labelStringID, label);
noteUTF16.Append(label);
noteUTF16.AppendLiteral("\n");
noteUTF16.Append( NS_ConvertASCIItoUTF16(extraData) );
noteUTF16.AppendLiteral("\n\n");
}
void nsEudoraAddress::SanitizeValue( nsCString& val)
@@ -810,17 +810,16 @@ void nsEudoraAddress::AddSingleCard( CAl
nsCString phoneWK, webLinkWK, title, company;
nsCString addressWK, address2WK, cityWK, stateWK, zipWK, countryWK;
nsCString primaryLocation, otherPhone, otherWeb;
nsCString additionalEmail, stillMoreEmail;
nsCString note(pEntry->m_notes);
nsString noteUTF16;
PRBool isSecondaryMobileWorkNumber = PR_TRUE;
PRBool isSecondaryFaxWorkNumber = PR_TRUE;
- nsCOMPtr<nsIStringBundle> bundle( dont_AddRef(nsEudoraStringBundle::GetStringBundleProxy()) );
if (!note.IsEmpty())
{
ExtractNoteField( note, fax, "fax");
ExtractNoteField( note, secondaryFax, "fax2");
ExtractNoteField( note, phone, "phone");
ExtractNoteField( note, mobile, "mobile");
ExtractNoteField( note, secondaryMobile, "mobile2");
@@ -873,35 +872,35 @@ void nsEudoraAddress::AddSingleCard( CAl
// Separate out the first address.
nsCString tempStashEmail(additionalEmail);
tempStashEmail.Left(additionalEmail, 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, bundle, stillMoreEmail, noteUTF16);
+ FormatExtraDataInNoteField(EUDORAIMPORT_ADDRESS_LABEL_OTHEREMAIL, stillMoreEmail, noteUTF16);
}
if ( !otherPhone.IsEmpty() )
{
// Reconstitute line breaks for other phone numbers
otherPhone.ReplaceSubstring( "\x03", "\n");
// Store other phone numbers in the notes field, labeled nicely
- FormatExtraDataInNoteField(EUDORAIMPORT_ADDRESS_LABEL_OTHERPHONE, bundle, otherPhone, noteUTF16);
+ FormatExtraDataInNoteField(EUDORAIMPORT_ADDRESS_LABEL_OTHERPHONE, otherPhone, noteUTF16);
}
if ( !otherWeb.IsEmpty() )
{
// Reconstitute line breaks for other web sites
otherWeb.ReplaceSubstring( "\x03", "\n");
// Store other web sites in the notes field, labeled nicely
- FormatExtraDataInNoteField(EUDORAIMPORT_ADDRESS_LABEL_OTHERWEB, bundle, otherWeb, noteUTF16);
+ FormatExtraDataInNoteField(EUDORAIMPORT_ADDRESS_LABEL_OTHERWEB, otherWeb, noteUTF16);
}
noteUTF16.Append( NS_ConvertASCIItoUTF16(note) );
}
}
CAliasData *pData = emailList.Count() ? (CAliasData *)emailList.ElementAt(0) : nsnull;
@@ -1013,27 +1012,27 @@ void nsEudoraAddress::AddSingleCard( CAl
nsString pFormat;
nsString pCustomData;
// Add second mobile number, if any, to the Custom 1 field
if ( !secondaryMobile.IsEmpty() )
{
stringID = isSecondaryMobileWorkNumber ?
EUDORAIMPORT_ADDRESS_LABEL_WORKMOBILE : EUDORAIMPORT_ADDRESS_LABEL_HOMEMOBILE;
- pFormat.Adopt( nsEudoraStringBundle::GetStringByID(stringID, bundle) );
+ pFormat.Adopt(nsEudoraStringBundle::GetStringByID(stringID));
pCustomData.Adopt( nsTextFormatter::smprintf(pFormat.get(), NS_ConvertASCIItoUTF16(secondaryMobile).get()) );
pDb->AddCustom1( newRow, NS_ConvertUTF16toUTF8(pCustomData).get() );
}
// Add second fax number, if any, to the Custom 2 field
if ( !secondaryFax.IsEmpty() )
{
stringID = isSecondaryFaxWorkNumber ?
EUDORAIMPORT_ADDRESS_LABEL_WORKFAX : EUDORAIMPORT_ADDRESS_LABEL_HOMEFAX;
- pFormat.Adopt( nsEudoraStringBundle::GetStringByID(stringID, bundle) );
+ pFormat.Adopt(nsEudoraStringBundle::GetStringByID(stringID));
pCustomData.Adopt( nsTextFormatter::smprintf(pFormat.get(), NS_ConvertASCIItoUTF16(secondaryFax).get()) );
pDb->AddCustom2( newRow, NS_ConvertUTF16toUTF8(pCustomData).get() );
}
// Lastly, note field.
pDb->AddNotes( newRow, NS_ConvertUTF16toUTF8(noteUTF16).get() );
pDb->AddCardRowToDB( newRow);
--- a/mailnews/import/eudora/src/nsEudoraAddress.h
+++ b/mailnews/import/eudora/src/nsEudoraAddress.h
@@ -84,17 +84,17 @@ private:
void ResolveEntries( nsCString& name, nsVoidArray& list, nsVoidArray& result, PRBool addResolvedEntries, PRBool wasResolved, PRInt32& numResolved);
void BuildABCards( PRUint32 *pBytes, nsIAddrDatabase *pDb);
void AddSingleCard( CAliasEntry *pEntry, nsVoidArray &emailList, nsIAddrDatabase *pDb);
nsresult AddSingleList( CAliasEntry *pEntry, nsVoidArray &emailList, nsIAddrDatabase *pDb);
nsresult AddGroupMembersAsCards(nsVoidArray &membersArray, nsIAddrDatabase *pDb);
void RememberGroupMembers(nsVoidArray &membersArray, nsVoidArray &emailList);
PRInt32 FindAlias( nsCString& name);
void ExtractNoteField( nsCString& note, nsCString& field, const char *pFieldName);
- void FormatExtraDataInNoteField(PRInt32 labelStringID, nsIStringBundle* bundle, nsCString& extraData, nsString& noteUTF16);
+ void FormatExtraDataInNoteField(PRInt32 labelStringID, nsCString& extraData, nsString& noteUTF16);
void SanitizeValue( nsCString& val);
void SplitString( nsCString& val1, nsCString& val2);
public:
static PRInt32 CountQuote( const char *pLine, PRInt32 len);
static PRInt32 CountComment( const char *pLine, PRInt32 len);
static PRInt32 CountAngle( const char *pLine, PRInt32 len);
--- a/mailnews/import/eudora/src/nsEudoraCompose.cpp
+++ b/mailnews/import/eudora/src/nsEudoraCompose.cpp
@@ -188,18 +188,16 @@ nsresult EudoraSendListener::CreateSendL
nsEudoraCompose::nsEudoraCompose()
{
m_pIOService = nsnull;
m_pAttachments = nsnull;
m_pListener = nsnull;
- m_pMsgSend = nsnull;
- m_pSendProxy = nsnull;
m_pMsgFields = nsnull;
m_pHeaders = p_test_headers;
if (m_pHeaders)
m_headerLen = strlen( m_pHeaders);
else
m_headerLen = 0;
m_pBody = p_test_body;
if (m_pBody)
@@ -208,19 +206,17 @@ nsEudoraCompose::nsEudoraCompose()
m_bodyLen = 0;
m_readHeaders.m_convertCRs = PR_TRUE;
}
nsEudoraCompose::~nsEudoraCompose()
{
- NS_IF_RELEASE( m_pSendProxy);
NS_IF_RELEASE( m_pIOService);
- NS_IF_RELEASE( m_pMsgSend);
NS_IF_RELEASE( m_pListener);
NS_IF_RELEASE( m_pMsgFields);
}
nsresult nsEudoraCompose::CreateIdentity( void)
{
if (s_pIdentity)
return( NS_OK);
@@ -268,33 +264,20 @@ nsresult nsEudoraCompose::CreateComponen
NS_WITH_PROXIED_SERVICE(nsIIOService, service, NS_IOSERVICE_CONTRACTID, NS_PROXY_TO_MAIN_THREAD, &rv);
if (NS_FAILED(rv))
return( rv);
m_pIOService = service;
NS_IF_ADDREF( m_pIOService);
}
NS_IF_RELEASE( m_pMsgFields);
- if (!m_pMsgSend) {
- rv = CallCreateInstance( kMsgSendCID, &m_pMsgSend);
- if (NS_SUCCEEDED( rv) && m_pMsgSend) {
- rv = NS_GetProxyForObject( NS_PROXY_TO_MAIN_THREAD, NS_GET_IID(nsIMsgSend),
- m_pMsgSend, NS_PROXY_SYNC, (void**)&m_pSendProxy);
- if (NS_FAILED( rv)) {
- m_pSendProxy = nsnull;
- NS_RELEASE( m_pMsgSend);
- m_pMsgSend = nsnull;
- }
- }
- }
- if (!m_pListener && NS_SUCCEEDED( rv)) {
+ if (!m_pListener && NS_SUCCEEDED( rv))
rv = EudoraSendListener::CreateSendListener( &m_pListener);
- }
- if (NS_SUCCEEDED(rv) && m_pMsgSend) {
+ if (NS_SUCCEEDED(rv)) {
rv = CallCreateInstance( kMsgCompFieldsCID, &m_pMsgFields);
if (NS_SUCCEEDED(rv) && m_pMsgFields) {
// IMPORT_LOG0( "nsOutlookCompose - CreateComponents succeeded\n");
m_pMsgFields->SetForcePlainText( PR_FALSE);
return( NS_OK);
}
}
@@ -709,67 +692,29 @@ nsresult nsEudoraCompose::SendTheMessage
// editor when it helps.
nsRefPtr<nsEudoraEditor> pEudoraEditor = new nsEudoraEditor(m_pBody, pMailImportLocation);
nsCOMPtr<nsIEditor> pEditor;
if (pEudoraEditor->HasEmbeddedContent())
// There's embedded content that we need to import, so query for the editor interface
pEudoraEditor->QueryInterface( NS_GET_IID(nsIEditor), getter_AddRefs(pEditor) );
- if (NS_FAILED( rv)) {
-
- rv = m_pSendProxy->CreateAndSendMessage(
- pEditor.get(), // pseudo editor shell when there's embedded content
- s_pIdentity, // dummy identity
- nsnull, // account key
- m_pMsgFields, // message fields
- PR_FALSE, // digest = NO
- PR_TRUE, // dont_deliver = YES, make a file
- mode, // mode
- nsnull, // no message to replace
- pMimeType, // body type
- m_pBody, // body pointer
- m_bodyLen, // body length
- nsnull, // remote attachment data
- pAttach, // local attachments
- nsnull, // related part
- nsnull, // parent window
- nsnull, // progress listener
- m_pListener, // listener
- nsnull, // password
- EmptyCString(), // originalMsgURI
- nsnull); // message compose type
+ nsCOMPtr<nsIImportService> impService(do_GetService(NS_IMPORTSERVICE_CONTRACTID, &rv));
+ NS_ENSURE_SUCCESS(rv, rv);
+ impService->ProxySend(pEditor, // pseudo editor shell when there's embedded content
+ s_pIdentity, // dummy identity
+ m_pMsgFields, // message fields
+ mode, // mode
+ pMimeType, // body type
+ body.get(), // body pointer
+ body.Length(), // body length
+ pAttach, // local attachments
+ m_pListener); // originalMsgURI
- }
- else {
- rv = m_pSendProxy->CreateAndSendMessage(
- pEditor.get(), // pseudo editor shell when there's embedded content
- s_pIdentity, // dummy identity
- nsnull, // account key
- m_pMsgFields, // message fields
- PR_FALSE, // digest = NO
- PR_TRUE, // dont_deliver = YES, make a file
- mode, // mode
- nsnull, // no message to replace
- pMimeType, // body type
- body.get(), // body pointer
- body.Length(), // body length
- nsnull, // remote attachment data
- pAttach, // local attachments
- nsnull, // related part
- nsnull, // parent window
- nsnull, // progress listener
- m_pListener, // listener
- nsnull, // password
- EmptyCString(), // originalMsgURI
- nsnull); // message compose type
-
- }
-
- // IMPORT_LOG0( "Returned from CreateAndSendMessage\n");
+ // IMPORT_LOG0( "Returned from ProxySend\n");
if (pAttach)
delete [] pAttach;
EudoraSendListener *pListen = (EudoraSendListener *)m_pListener;
if (NS_FAILED( rv)) {
IMPORT_LOG1( "*** Error, CreateAndSendMessage FAILED: 0x%lx\n", rv);
// IMPORT_LOG1( "Headers: %80s\n", m_pHeaders);
--- a/mailnews/import/eudora/src/nsEudoraCompose.h
+++ b/mailnews/import/eudora/src/nsEudoraCompose.h
@@ -170,18 +170,16 @@ private:
nsresult WriteHeaders( nsIOutputStream *pDst, SimpleBufferTonyRCopiedOnce& newHeaders);
PRBool IsReplaceHeader( const char *pHeader);
private:
static nsIMsgIdentity * s_pIdentity;
nsVoidArray * m_pAttachments;
nsIMsgSendListener * m_pListener;
- nsIMsgSend * m_pMsgSend;
- nsIMsgSend * m_pSendProxy;
nsIMsgCompFields * m_pMsgFields;
nsIIOService * m_pIOService;
PRInt32 m_headerLen;
const char * m_pHeaders;
PRInt32 m_bodyLen;
const char * m_pBody;
nsCString m_bodyType;
nsString m_defCharset;
--- a/mailnews/import/eudora/src/nsEudoraImport.cpp
+++ b/mailnews/import/eudora/src/nsEudoraImport.cpp
@@ -483,39 +483,35 @@ void ImportEudoraMailImpl::AddLinebreak(
pStream->Append( PRUnichar('\n'));
}
void ImportEudoraMailImpl::ReportSuccess( nsString& name, PRInt32 count, nsString *pStream)
{
if (!pStream)
return;
// load the success string
- nsIStringBundle *pBundle = nsEudoraStringBundle::GetStringBundleProxy();
- PRUnichar *pFmt = nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_MAILBOX_SUCCESS, pBundle);
+ PRUnichar *pFmt = nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_MAILBOX_SUCCESS);
PRUnichar *pText = nsTextFormatter::smprintf( pFmt, name.get(), count);
pStream->Append( pText);
nsTextFormatter::smprintf_free( pText);
nsEudoraStringBundle::FreeString( pFmt);
AddLinebreak( pStream);
- NS_IF_RELEASE( pBundle);
}
void ImportEudoraMailImpl::ReportError( PRInt32 errorNum, nsString& name, nsString *pStream)
{
if (!pStream)
return;
// load the error string
- nsIStringBundle *pBundle = nsEudoraStringBundle::GetStringBundleProxy();
- PRUnichar *pFmt = nsEudoraStringBundle::GetStringByID( errorNum);
- PRUnichar *pText = nsTextFormatter::smprintf( pFmt, name.get());
+ PRUnichar *pFmt = nsEudoraStringBundle::GetStringByID(errorNum);
+ PRUnichar *pText = nsTextFormatter::smprintf(pFmt, name.get());
pStream->Append( pText);
nsTextFormatter::smprintf_free( pText);
nsEudoraStringBundle::FreeString( pFmt);
AddLinebreak( pStream);
- NS_IF_RELEASE( pBundle);
}
void ImportEudoraMailImpl::SetLogs( nsString& success, nsString& error, PRUnichar **pError, PRUnichar **pSuccess)
{
if (pError)
*pError = ToNewUnicode(error);
if (pSuccess)
@@ -528,24 +524,24 @@ NS_IMETHODIMP ImportEudoraMailImpl::Impo
PRUnichar **pSuccessLog,
PRBool *fatalError)
{
NS_PRECONDITION(pSource != nsnull, "null ptr");
NS_PRECONDITION(pDestination != nsnull, "null ptr");
NS_PRECONDITION(fatalError != nsnull, "null ptr");
- nsCOMPtr<nsIStringBundle> bundle( dont_AddRef( nsEudoraStringBundle::GetStringBundleProxy()));
+ nsCOMPtr<nsIStringBundle> bundle( dont_AddRef( nsEudoraStringBundle::GetStringBundle()));
nsString success;
nsString error;
if (!pSource || !pDestination || !fatalError)
{
IMPORT_LOG0( "*** Bad param passed to eudora mailbox import\n");
- nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_MAILBOX_BADPARAM, error, bundle);
+ nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_MAILBOX_BADPARAM, error);
if (fatalError)
*fatalError = PR_TRUE;
SetLogs( success, error, pErrorLog, pSuccessLog);
return NS_ERROR_NULL_POINTER;
}
PRBool abort = PR_FALSE;
nsString name;
@@ -706,47 +702,43 @@ NS_IMETHODIMP ImportEudoraAddressImpl::F
void ImportEudoraAddressImpl::ReportSuccess( nsString& name, nsString *pStream)
{
if (!pStream)
return;
// load the success string
- nsIStringBundle *pBundle = nsEudoraStringBundle::GetStringBundleProxy();
- PRUnichar *pFmt = nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_ADDRESS_SUCCESS, pBundle);
+ PRUnichar *pFmt = nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_ADDRESS_SUCCESS);
PRUnichar *pText = nsTextFormatter::smprintf( pFmt, name.get());
pStream->Append( pText);
nsTextFormatter::smprintf_free( pText);
nsEudoraStringBundle::FreeString( pFmt);
ImportEudoraMailImpl::AddLinebreak( pStream);
- NS_IF_RELEASE( pBundle);
}
NS_IMETHODIMP
ImportEudoraAddressImpl::ImportAddressBook(nsIImportABDescriptor *pSource,
nsIAddrDatabase *pDestination,
nsIImportFieldMap *fieldMap,
nsISupports *aSupportService,
PRUnichar **pErrorLog,
PRUnichar **pSuccessLog,
PRBool *fatalError)
{
NS_PRECONDITION(pSource != nsnull, "null ptr");
NS_PRECONDITION(pDestination != nsnull, "null ptr");
NS_PRECONDITION(fatalError != nsnull, "null ptr");
- nsCOMPtr<nsIStringBundle> bundle( dont_AddRef( nsEudoraStringBundle::GetStringBundleProxy()));
-
nsString success;
nsString error;
if (!pSource || !pDestination || !fatalError) {
IMPORT_LOG0( "*** Bad param passed to eudora address import\n");
- nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_ADDRESS_BADPARAM, error, bundle);
+ nsEudoraStringBundle::GetStringByID(EUDORAIMPORT_ADDRESS_BADPARAM, error);
if (fatalError)
*fatalError = PR_TRUE;
ImportEudoraMailImpl::SetLogs( success, error, pErrorLog, pSuccessLog);
return NS_ERROR_NULL_POINTER;
}
PRBool abort = PR_FALSE;
nsString name;
--- a/mailnews/import/eudora/src/nsEudoraStringBundle.cpp
+++ b/mailnews/import/eudora/src/nsEudoraStringBundle.cpp
@@ -39,73 +39,58 @@
#include "prprf.h"
#include "prmem.h"
#include "nsCOMPtr.h"
#include "nsReadableUtils.h"
#include "nsIStringBundle.h"
#include "nsEudoraStringBundle.h"
#include "nsIServiceManager.h"
-#include "nsIProxyObjectManager.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)
{
if (m_pBundle)
- return( m_pBundle);
+ return m_pBundle;
nsresult rv;
const char* propertyURL = EUDORA_MSGS_URL;
nsIStringBundle* sBundle = nsnull;
nsCOMPtr<nsIStringBundleService> sBundleService =
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv) && (nsnull != sBundleService))
rv = sBundleService->CreateBundle(propertyURL, &sBundle);
m_pBundle = sBundle;
return( sBundle);
}
-nsIStringBundle *nsEudoraStringBundle::GetStringBundleProxy( void)
-{
- if (!m_pBundle)
- return( nsnull);
-
- nsIStringBundle *strProxy = nsnull;
- // create a proxy object if we aren't on the same thread?
- NS_GetProxyForObject(NS_PROXY_TO_MAIN_THREAD, NS_GET_IID(nsIStringBundle),
- m_pBundle, NS_PROXY_SYNC | NS_PROXY_ALWAYS,
- (void **) &strProxy);
-
- return( strProxy);
-}
-
-void nsEudoraStringBundle::GetStringByID( PRInt32 stringID, nsString& result, nsIStringBundle *pBundle)
+void nsEudoraStringBundle::GetStringByID( PRInt32 stringID, nsString& result)
{
- PRUnichar *ptrv = GetStringByID( stringID, pBundle);
+ PRUnichar *ptrv = GetStringByID(stringID);
result = ptrv;
FreeString( ptrv);
}
-PRUnichar *nsEudoraStringBundle::GetStringByID(PRInt32 stringID, nsIStringBundle *pBundle)
+PRUnichar *nsEudoraStringBundle::GetStringByID(PRInt32 stringID)
{
- if (!pBundle)
- pBundle = GetStringBundle();
+ if (!m_pBundle)
+ m_pBundle = GetStringBundle();
- if (pBundle)
+ if (m_pBundle)
{
PRUnichar *ptrv = nsnull;
- nsresult rv = pBundle->GetStringFromID(stringID, &ptrv);
+ nsresult rv = m_pBundle->GetStringFromID(stringID, &ptrv);
if (NS_SUCCEEDED( rv) && ptrv)
return( ptrv);
}
nsString resultString(NS_LITERAL_STRING("[StringID "));
resultString.AppendInt(stringID);
resultString.AppendLiteral("?]");
--- a/mailnews/import/eudora/src/nsEudoraStringBundle.h
+++ b/mailnews/import/eudora/src/nsEudoraStringBundle.h
@@ -40,21 +40,20 @@
#define nsEudoraStringBundle_H__
#include "nsString.h"
class nsIStringBundle;
class nsEudoraStringBundle {
public:
- static PRUnichar * GetStringByID(PRInt32 stringID, nsIStringBundle *pBundle = nsnull);
- static void GetStringByID(PRInt32 stringID, nsString& result, nsIStringBundle *pBundle = nsnull);
+ static PRUnichar * GetStringByID(PRInt32 stringID);
+ static void GetStringByID(PRInt32 stringID, nsString& result);
static nsString FormatString(PRInt32 stringID, ...);
static nsIStringBundle * GetStringBundle( void); // don't release
- static nsIStringBundle * GetStringBundleProxy( void); // release
static void FreeString( PRUnichar *pStr) { NS_Free( pStr);}
static void Cleanup( void);
private:
static nsIStringBundle * m_pBundle;
};
--- a/mailnews/import/oexpress/nsOEImport.cpp
+++ b/mailnews/import/oexpress/nsOEImport.cpp
@@ -385,39 +385,35 @@ void ImportOEMailImpl::AddLinebreak( nsS
pStream->Append( PRUnichar('\n'));
}
void ImportOEMailImpl::ReportSuccess( nsString& name, PRInt32 count, nsString *pStream)
{
if (!pStream)
return;
// load the success string
- nsIStringBundle *pBundle = nsOEStringBundle::GetStringBundleProxy();
- PRUnichar *pFmt = nsOEStringBundle::GetStringByID( OEIMPORT_MAILBOX_SUCCESS, pBundle);
+ PRUnichar *pFmt = nsOEStringBundle::GetStringByID( OEIMPORT_MAILBOX_SUCCESS);
PRUnichar *pText = nsTextFormatter::smprintf( pFmt, name.get(), count);
pStream->Append( pText);
nsTextFormatter::smprintf_free( pText);
nsOEStringBundle::FreeString( pFmt);
AddLinebreak( pStream);
- NS_IF_RELEASE( pBundle);
}
void ImportOEMailImpl::ReportError( PRInt32 errorNum, nsString& name, nsString *pStream)
{
if (!pStream)
return;
// load the error string
- nsIStringBundle *pBundle = nsOEStringBundle::GetStringBundleProxy();
- PRUnichar *pFmt = nsOEStringBundle::GetStringByID( errorNum, pBundle);
+ PRUnichar *pFmt = nsOEStringBundle::GetStringByID(errorNum);
PRUnichar *pText = nsTextFormatter::smprintf( pFmt, name.get());
pStream->Append( pText);
nsTextFormatter::smprintf_free( pText);
nsOEStringBundle::FreeString( pFmt);
AddLinebreak( pStream);
- NS_IF_RELEASE( pBundle);
}
void ImportOEMailImpl::SetLogs( nsString& success, nsString& error, PRUnichar **pError, PRUnichar **pSuccess)
{
if (pError)
*pError = ToNewUnicode(error);
if (pSuccess)
@@ -429,22 +425,20 @@ NS_IMETHODIMP ImportOEMailImpl::ImportMa
PRUnichar **pErrorLog,
PRUnichar **pSuccessLog,
PRBool *fatalError)
{
NS_PRECONDITION(pSource != nsnull, "null ptr");
NS_PRECONDITION(pDestination != nsnull, "null ptr");
NS_PRECONDITION(fatalError != nsnull, "null ptr");
- nsCOMPtr<nsIStringBundle> bundle( dont_AddRef( nsOEStringBundle::GetStringBundleProxy()));
-
nsString success;
nsString error;
if (!pSource || !pDestination || !fatalError) {
- nsOEStringBundle::GetStringByID( OEIMPORT_MAILBOX_BADPARAM, error, bundle);
+ nsOEStringBundle::GetStringByID( OEIMPORT_MAILBOX_BADPARAM, error);
if (fatalError)
*fatalError = PR_TRUE;
SetLogs( success, error, pErrorLog, pSuccessLog);
return NS_ERROR_NULL_POINTER;
}
PRBool abort = PR_FALSE;
nsString name;
@@ -611,22 +605,21 @@ NS_IMETHODIMP ImportOEAddressImpl::Impor
// we assume it is our one and only address book.
if (!m_pWab) {
IMPORT_LOG0( "Wab not loaded in ImportAddressBook call\n");
return( NS_ERROR_FAILURE);
}
IMPORT_LOG0( "IMPORTING OUTLOOK EXPRESS ADDRESS BOOK\n");
- nsCOMPtr<nsIStringBundle> bundle( dont_AddRef( nsOEStringBundle::GetStringBundleProxy()));
nsString success;
nsString error;
if (!source || !destination || !fatalError)
{
- nsOEStringBundle::GetStringByID( OEIMPORT_ADDRESS_BADPARAM, error, bundle);
+ nsOEStringBundle::GetStringByID( OEIMPORT_ADDRESS_BADPARAM, error);
if (fatalError)
*fatalError = PR_TRUE;
ImportOEMailImpl::SetLogs( success, error, errorLog, successLog);
return NS_ERROR_NULL_POINTER;
}
m_doneSoFar = 0;
nsOEAddressIterator * pIter = new nsOEAddressIterator( m_pWab, destination);
@@ -661,17 +654,15 @@ NS_IMETHODIMP ImportOEAddressImpl::GetIm
return( NS_OK);
}
void ImportOEAddressImpl::ReportSuccess( nsString& name, nsString *pStream)
{
if (!pStream)
return;
// load the success string
- nsIStringBundle *pBundle = nsOEStringBundle::GetStringBundleProxy();
- PRUnichar *pFmt = nsOEStringBundle::GetStringByID( OEIMPORT_ADDRESS_SUCCESS, pBundle);
+ PRUnichar *pFmt = nsOEStringBundle::GetStringByID( OEIMPORT_ADDRESS_SUCCESS);
PRUnichar *pText = nsTextFormatter::smprintf( pFmt, name.get());
pStream->Append( pText);
nsTextFormatter::smprintf_free( pText);
nsOEStringBundle::FreeString( pFmt);
ImportOEMailImpl::AddLinebreak( pStream);
- NS_IF_RELEASE( pBundle);
}
--- a/mailnews/import/oexpress/nsOEStringBundle.cpp
+++ b/mailnews/import/oexpress/nsOEStringBundle.cpp
@@ -36,17 +36,16 @@
* ***** END LICENSE BLOCK ***** */
#include "prprf.h"
#include "prmem.h"
#include "nsCOMPtr.h"
#include "nsReadableUtils.h"
#include "nsIStringBundle.h"
#include "nsOEStringBundle.h"
#include "nsIServiceManager.h"
-#include "nsIProxyObjectManager.h"
#include "nsIURI.h"
#define OE_MSGS_URL "chrome://messenger/locale/oeImportMsgs.properties"
nsIStringBundle * nsOEStringBundle::m_pBundle = nsnull;
nsIStringBundle *nsOEStringBundle::GetStringBundle( void)
{
@@ -64,47 +63,32 @@ nsIStringBundle *nsOEStringBundle::GetSt
rv = sBundleService->CreateBundle(propertyURL, &sBundle);
}
m_pBundle = sBundle;
return( sBundle);
}
-nsIStringBundle *nsOEStringBundle::GetStringBundleProxy( void)
+
+void nsOEStringBundle::GetStringByID( PRInt32 stringID, nsString& result)
{
- if (!m_pBundle)
- return( nsnull);
-
- nsIStringBundle *strProxy = nsnull;
- // create a proxy object if we aren't on the same thread?
- NS_GetProxyForObject(NS_PROXY_TO_MAIN_THREAD, NS_GET_IID(nsIStringBundle),
- m_pBundle, NS_PROXY_SYNC | NS_PROXY_ALWAYS,
- (void **) &strProxy);
-
- return( strProxy);
-}
-
-void nsOEStringBundle::GetStringByID( PRInt32 stringID, nsString& result, nsIStringBundle *pBundle)
-{
-
- PRUnichar *ptrv = GetStringByID( stringID, pBundle);
+ PRUnichar *ptrv = GetStringByID( stringID);
result = ptrv;
FreeString( ptrv);
}
-PRUnichar *nsOEStringBundle::GetStringByID(PRInt32 stringID, nsIStringBundle *pBundle)
+PRUnichar *nsOEStringBundle::GetStringByID(PRInt32 stringID)
{
- if (!pBundle) {
- pBundle = GetStringBundle();
- }
+ if (!m_pBundle)
+ m_pBundle = GetStringBundle();
- if (pBundle) {
+ if (m_pBundle) {
PRUnichar *ptrv = nsnull;
- nsresult rv = pBundle->GetStringFromID(stringID, &ptrv);
+ nsresult rv = m_pBundle->GetStringFromID(stringID, &ptrv);
if (NS_SUCCEEDED( rv) && ptrv)
return( ptrv);
}
nsString resultString;
resultString.AppendLiteral("[StringID ");
resultString.AppendInt(stringID);
--- a/mailnews/import/oexpress/nsOEStringBundle.h
+++ b/mailnews/import/oexpress/nsOEStringBundle.h
@@ -38,22 +38,21 @@
#define _nsOEStringBundle_H__
#include "nsString.h"
class nsIStringBundle;
class nsOEStringBundle {
public:
- static PRUnichar * GetStringByID(PRInt32 stringID, nsIStringBundle *pBundle = nsnull);
- static void GetStringByID(PRInt32 stringID, nsString& result, nsIStringBundle *pBundle = nsnull);
+ static PRUnichar * GetStringByID(PRInt32 stringID);
+ static void GetStringByID(PRInt32 stringID, nsString& result);
static nsIStringBundle * GetStringBundle( void); // don't release
static void FreeString( PRUnichar *pStr) { NS_Free( pStr);}
static void Cleanup( void);
- static nsIStringBundle * GetStringBundleProxy( void); // release
private:
static nsIStringBundle * m_pBundle;
};
#define OEIMPORT_NAME 2000
--- a/mailnews/import/outlook/src/nsOutlookCompose.cpp
+++ b/mailnews/import/outlook/src/nsOutlookCompose.cpp
@@ -217,29 +217,25 @@ nsresult OutlookSendListener::CreateSend
#define hackCRLFA "crlf"
#define hackCRLFW NS_L(hackCRLFA)
#define hackAmpersandA "amp"
#define hackAmpersandW NS_L(hackAmpersandA)
nsOutlookCompose::nsOutlookCompose()
{
m_pListener = nsnull;
- m_pMsgSend = nsnull;
- m_pSendProxy = nsnull;
m_pMsgFields = nsnull;
m_pIdentity = nsnull;
m_optimizationBufferSize = 16*1024;
m_optimizationBuffer = new char[m_optimizationBufferSize];
}
nsOutlookCompose::~nsOutlookCompose()
{
- NS_IF_RELEASE(m_pSendProxy);
- NS_IF_RELEASE(m_pMsgSend);
NS_IF_RELEASE(m_pListener);
NS_IF_RELEASE(m_pMsgFields);
if (m_pIdentity) {
nsresult rv = m_pIdentity->ClearAllValues();
NS_ASSERTION(NS_SUCCEEDED(rv),"failed to clear values");
if (NS_FAILED(rv))
return;
@@ -277,32 +273,20 @@ nsresult nsOutlookCompose::CreateIdentit
return rv;
}
nsresult nsOutlookCompose::CreateComponents( void)
{
nsresult rv = NS_OK;
NS_IF_RELEASE(m_pMsgFields);
- if (!m_pMsgSend) {
- rv = CallCreateInstance( kMsgSendCID, &m_pMsgSend);
- if (NS_SUCCEEDED( rv) && m_pMsgSend) {
- rv = NS_GetProxyForObject( NS_PROXY_TO_MAIN_THREAD, NS_GET_IID(nsIMsgSend),
- m_pMsgSend, NS_PROXY_SYNC, (void **)&m_pSendProxy);
- if (NS_FAILED( rv)) {
- m_pSendProxy = nsnull;
- NS_RELEASE(m_pMsgSend);
- }
- }
- }
- if (!m_pListener && NS_SUCCEEDED( rv)) {
+ if (!m_pListener && NS_SUCCEEDED( rv))
rv = OutlookSendListener::CreateSendListener( &m_pListener);
- }
- if (NS_SUCCEEDED(rv) && m_pMsgSend) {
+ if (NS_SUCCEEDED(rv)) {
rv = CallCreateInstance( kMsgCompFieldsCID, &m_pMsgFields);
if (NS_SUCCEEDED(rv) && m_pMsgFields) {
// IMPORT_LOG0( "nsOutlookCompose - CreateComponents succeeded\n");
m_pMsgFields->SetForcePlainText( PR_FALSE);
return NS_OK;
}
}
@@ -374,37 +358,29 @@ nsresult nsOutlookCompose::ComposeTheMes
else {
if (bodyW.IsEmpty())
msg.GetBody(bodyA);
else
nsMsgI18NConvertFromUnicode(msg.GetBodyCharset(), bodyW, bodyA);
}
// IMPORT_LOG0( "Outlook compose calling CreateAndSendMessage\n");
- rv = m_pSendProxy->CreateAndSendMessage(
+ nsCOMPtr<nsIImportService> impService(do_GetService(NS_IMPORTSERVICE_CONTRACTID, &rv));
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ rv = impService->ProxySend(
pEditor, // editor shell
m_pIdentity, // dummy identity
- nsnull, // account key
m_pMsgFields, // message fields
- PR_FALSE, // digest = NO
- PR_TRUE, // dont_deliver = YES, make a file
mode, // mode
- nsnull, // no message to replace
msg.BodyIsHtml() ? "text/html" : "text/plain", // body type
bodyA.get(), // body pointer
bodyA.Length(), // body length
- nsnull, // remote attachment data
pAttach, // local attachments
- nsnull, // related part
- nsnull, // parent window
- nsnull, // progress listener
- m_pListener, // listener
- nsnull, // password
- EmptyCString(), // originalMsgURI
- nsnull); // message compose type
+ m_pListener); // originalMsgURI
// IMPORT_LOG0( "Returned from CreateAndSendMessage\n");
OutlookSendListener *pListen = (OutlookSendListener *)m_pListener;
if (NS_FAILED(rv)) {
IMPORT_LOG1( "*** Error, CreateAndSendMessage FAILED: 0x%lx\n", rv);
}
else {
// wait for the listener to get done!
--- a/mailnews/import/outlook/src/nsOutlookCompose.h
+++ b/mailnews/import/outlook/src/nsOutlookCompose.h
@@ -98,18 +98,16 @@ private:
void operator () (const CidReplacePair* pair);
private:
nsCString& m_line;
bool m_finishedReplacing;
};
nsIMsgSendListener * m_pListener;
- nsIMsgSend * m_pMsgSend;
- nsIMsgSend * m_pSendProxy;
nsIMsgCompFields * m_pMsgFields;
nsIMsgIdentity * m_pIdentity;
char* m_optimizationBuffer;
unsigned int m_optimizationBufferSize;
nsCOMPtr<nsIImportService> m_pImportService;
// Bug 593907
nsString m_hackedPostfix;
--- a/mailnews/import/outlook/src/nsOutlookImport.cpp
+++ b/mailnews/import/outlook/src/nsOutlookImport.cpp
@@ -383,39 +383,35 @@ void ImportOutlookMailImpl::AddLinebreak
pStream->Append( PRUnichar('\n'));
}
void ImportOutlookMailImpl::ReportSuccess( nsString& name, PRInt32 count, nsString *pStream)
{
if (!pStream)
return;
// load the success string
- nsIStringBundle *pBundle = nsOutlookStringBundle::GetStringBundleProxy();
- PRUnichar *pFmt = nsOutlookStringBundle::GetStringByID( OUTLOOKIMPORT_MAILBOX_SUCCESS, pBundle);
+ PRUnichar *pFmt = nsOutlookStringBundle::GetStringByID( OUTLOOKIMPORT_MAILBOX_SUCCESS);
PRUnichar *pText = nsTextFormatter::smprintf( pFmt, name.get(), count);
pStream->Append( pText);
nsTextFormatter::smprintf_free( pText);
nsOutlookStringBundle::FreeString( pFmt);
AddLinebreak( pStream);
- NS_IF_RELEASE( pBundle);
}
void ImportOutlookMailImpl::ReportError( PRInt32 errorNum, nsString& name, nsString *pStream)
{
if (!pStream)
return;
// load the error string
- nsIStringBundle *pBundle = nsOutlookStringBundle::GetStringBundleProxy();
- PRUnichar *pFmt = nsOutlookStringBundle::GetStringByID( errorNum);
+ PRUnichar *pFmt = nsOutlookStringBundle::GetStringByID(errorNum);
PRUnichar *pText = nsTextFormatter::smprintf( pFmt, name.get());
pStream->Append( pText);
nsTextFormatter::smprintf_free( pText);
nsOutlookStringBundle::FreeString( pFmt);
AddLinebreak( pStream);
- NS_IF_RELEASE( pBundle);
}
void ImportOutlookMailImpl::SetLogs( nsString& success, nsString& error, PRUnichar **pError, PRUnichar **pSuccess)
{
if (pError)
*pError = ToNewUnicode(error);
if (pSuccess)
@@ -427,22 +423,20 @@ NS_IMETHODIMP ImportOutlookMailImpl::Imp
PRUnichar **pErrorLog,
PRUnichar **pSuccessLog,
PRBool *fatalError)
{
NS_PRECONDITION(pSource != nsnull, "null ptr");
NS_PRECONDITION(pDestination != nsnull, "null ptr");
NS_PRECONDITION(fatalError != nsnull, "null ptr");
- nsCOMPtr<nsIStringBundle> bundle( dont_AddRef( nsOutlookStringBundle::GetStringBundleProxy()));
-
nsString success;
nsString error;
if (!pSource || !pDestination || !fatalError) {
- nsOutlookStringBundle::GetStringByID( OUTLOOKIMPORT_MAILBOX_BADPARAM, error, bundle);
+ nsOutlookStringBundle::GetStringByID( OUTLOOKIMPORT_MAILBOX_BADPARAM, error);
if (fatalError)
*fatalError = PR_TRUE;
SetLogs( success, error, pErrorLog, pSuccessLog);
return NS_ERROR_NULL_POINTER;
}
PRBool abort = PR_FALSE;
nsString name;
@@ -561,23 +555,21 @@ NS_IMETHODIMP ImportOutlookAddressImpl::
PRBool *fatalError)
{
m_msgCount = 0;
m_msgTotal = 0;
NS_PRECONDITION(source != nsnull, "null ptr");
NS_PRECONDITION(destination != nsnull, "null ptr");
NS_PRECONDITION(fatalError != nsnull, "null ptr");
- nsCOMPtr<nsIStringBundle> bundle( dont_AddRef( nsOutlookStringBundle::GetStringBundleProxy()));
-
nsString success;
nsString error;
if (!source || !destination || !fatalError) {
IMPORT_LOG0( "*** Bad param passed to outlook address import\n");
- nsOutlookStringBundle::GetStringByID( OUTLOOKIMPORT_ADDRESS_BADPARAM, error, bundle);
+ nsOutlookStringBundle::GetStringByID( OUTLOOKIMPORT_ADDRESS_BADPARAM, error);
if (fatalError)
*fatalError = PR_TRUE;
ImportOutlookMailImpl::SetLogs( success, error, pErrorLog, pSuccessLog);
return NS_ERROR_NULL_POINTER;
}
nsString name;
source->GetPreferredName(name);
@@ -624,17 +616,15 @@ NS_IMETHODIMP ImportOutlookAddressImpl::
return( NS_OK);
}
void ImportOutlookAddressImpl::ReportSuccess( nsString& name, nsString *pStream)
{
if (!pStream)
return;
// load the success string
- nsIStringBundle *pBundle = nsOutlookStringBundle::GetStringBundleProxy();
- PRUnichar *pFmt = nsOutlookStringBundle::GetStringByID( OUTLOOKIMPORT_ADDRESS_SUCCESS, pBundle);
+ PRUnichar *pFmt = nsOutlookStringBundle::GetStringByID(OUTLOOKIMPORT_ADDRESS_SUCCESS);
PRUnichar *pText = nsTextFormatter::smprintf( pFmt, name.get());
pStream->Append( pText);
nsTextFormatter::smprintf_free( pText);
nsOutlookStringBundle::FreeString( pFmt);
ImportOutlookMailImpl::AddLinebreak( pStream);
- NS_IF_RELEASE( pBundle);
}
--- a/mailnews/import/outlook/src/nsOutlookStringBundle.cpp
+++ b/mailnews/import/outlook/src/nsOutlookStringBundle.cpp
@@ -46,17 +46,17 @@
#define OUTLOOK_MSGS_URL "chrome://messenger/locale/outlookImportMsgs.properties"
nsIStringBundle * nsOutlookStringBundle::m_pBundle = nsnull;
nsIStringBundle *nsOutlookStringBundle::GetStringBundle( void)
{
if (m_pBundle)
- return( m_pBundle);
+ return m_pBundle;
nsresult rv;
char* propertyURL = OUTLOOK_MSGS_URL;
nsIStringBundle* sBundle = nsnull;
nsCOMPtr<nsIStringBundleService> sBundleService =
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
@@ -64,49 +64,34 @@ nsIStringBundle *nsOutlookStringBundle::
rv = sBundleService->CreateBundle(propertyURL, &sBundle);
}
m_pBundle = sBundle;
return( sBundle);
}
-nsIStringBundle *nsOutlookStringBundle::GetStringBundleProxy( void)
+void nsOutlookStringBundle::GetStringByID( PRInt32 stringID, nsString& result)
{
- if (!m_pBundle)
- return( nsnull);
-
- nsIStringBundle *strProxy = nsnull;
- // create a proxy object if we aren't on the same thread?
- NS_GetProxyForObject( NS_PROXY_TO_MAIN_THREAD, NS_GET_IID(nsIStringBundle),
- m_pBundle, NS_PROXY_SYNC | NS_PROXY_ALWAYS, (void **) &strProxy);
-
- return( strProxy);
-}
-
-void nsOutlookStringBundle::GetStringByID( PRInt32 stringID, nsString& result, nsIStringBundle *pBundle)
-{
-
- PRUnichar *ptrv = GetStringByID( stringID, pBundle);
+ PRUnichar *ptrv = GetStringByID(stringID);
result = ptrv;
FreeString( ptrv);
}
-PRUnichar *nsOutlookStringBundle::GetStringByID(PRInt32 stringID, nsIStringBundle *pBundle)
+PRUnichar *nsOutlookStringBundle::GetStringByID(PRInt32 stringID)
{
- if (!pBundle) {
- pBundle = GetStringBundle();
- }
+ if (m_pBundle)
+ m_pBundle = GetStringBundle();
- if (pBundle) {
+ if (m_pBundle) {
PRUnichar *ptrv = nsnull;
- nsresult rv = pBundle->GetStringFromID(stringID, &ptrv);
+ nsresult rv = m_pBundle->GetStringFromID(stringID, &ptrv);
if (NS_SUCCEEDED( rv) && ptrv)
- return( ptrv);
+ return ptrv;
}
nsString resultString;
resultString.AppendLiteral("[StringID ");
resultString.AppendInt(stringID);
resultString.AppendLiteral("?]");
return ToNewUnicode(resultString);
--- a/mailnews/import/outlook/src/nsOutlookStringBundle.h
+++ b/mailnews/import/outlook/src/nsOutlookStringBundle.h
@@ -39,23 +39,22 @@
#include "nsCRTGlue.h"
#include "nsString.h"
class nsIStringBundle;
class nsOutlookStringBundle {
public:
- static PRUnichar * GetStringByID(PRInt32 stringID, nsIStringBundle *pBundle = nsnull);
- static void GetStringByID(PRInt32 stringID, nsString& result, nsIStringBundle *pBundle = nsnull);
+ static PRUnichar * GetStringByID(PRInt32 stringID);
+ static void GetStringByID(PRInt32 stringID, nsString& result);
static nsIStringBundle * GetStringBundle( void); // don't release
- static nsIStringBundle * GetStringBundleProxy( void); // release
static void FreeString( PRUnichar *pStr) { NS_Free( pStr);}
static void Cleanup( void);
- private:
+private:
static nsIStringBundle * m_pBundle;
};
#define OUTLOOKIMPORT_NAME 2000
#define OUTLOOKIMPORT_DESCRIPTION 2010
#define OUTLOOKIMPORT_MAILBOX_SUCCESS 2002
--- a/mailnews/import/public/nsIImportService.idl
+++ b/mailnews/import/public/nsIImportService.idl
@@ -37,40 +37,53 @@
/*
The import service.
*/
#include "nsISupports.idl"
+#include "nsIMsgSend.idl"
interface nsIImportModule;
interface nsIImportMailboxDescriptor;
interface nsIImportABDescriptor;
interface nsIImportGeneric;
interface nsIImportFieldMap;
+interface nsIMsgSendListener;
+interface nsIMsgCompFields;
+interface nsIMsgSendListener;
-[scriptable, uuid(c035e4a5-6dcc-4c70-8ff7-5b740bd2ed2b)]
+[scriptable, uuid(55a52e05-8ce7-4e23-8a2f-a9226b01bcfb)]
interface nsIImportService : nsISupports
{
void DiscoverModules();
long GetModuleCount( in string filter);
void GetModuleInfo( in string filter, in long index, out wstring name, out wstring description);
wstring GetModuleName( in string filter, in long index);
wstring GetModuleDescription( in string filter, in long index);
nsIImportModule GetModule( in string filter, in long index);
nsIImportModule GetModuleWithCID( in nsCIDRef cid);
nsIImportFieldMap CreateNewFieldMap();
nsIImportMailboxDescriptor CreateNewMailboxDescriptor();
nsIImportABDescriptor CreateNewABDescriptor();
nsIImportGeneric CreateNewGenericMail();
nsIImportGeneric CreateNewGenericAddressBooks();
+ [noscript] void ProxySend(in nsIEditor aEditor, in nsIMsgIdentity aIdentity,
+ in nsIMsgCompFields aMsgFields,
+ in nsMsgDeliverMode aDeliverMode,
+ in string attachment1_type,
+ in string attachment1_body,
+ in PRUint32 attachment1_body_length,
+ [const] in nsMsgAttachedFile loaded_attachments,
+ in nsIMsgSendListener aListener);
+
};
%{ C++
#define NS_IMPORTSERVICE_CID \
{ /* 5df96d60-1726-11d3-a206-00a0cc26da63 */ \
0x5df96d60, 0x1726, 0x11d3, \
{0xa2, 0x06, 0x0, 0xa0, 0xcc, 0x26, 0xda, 0x63}}
--- a/mailnews/import/src/nsImportFieldMap.cpp
+++ b/mailnews/import/src/nsImportFieldMap.cpp
@@ -71,18 +71,17 @@ nsImportFieldMap::nsImportFieldMap(nsISt
{
m_numFields = 0;
m_pFields = nsnull;
m_pActive = nsnull;
m_allocated = 0;
// need to init the description array
m_mozFieldCount = 0;
m_skipFirstRecord = false;
- nsCOMPtr<nsIStringBundle> pBundle;
- nsImportStringBundle::GetStringBundleProxy(aBundle, getter_AddRefs(pBundle));
+ nsCOMPtr<nsIStringBundle> pBundle = aBundle;
nsString *pStr;
for (PRInt32 i = IMPORT_FIELD_DESC_START; i <= IMPORT_FIELD_DESC_END; i++, m_mozFieldCount++) {
pStr = new nsString();
if (pBundle) {
nsImportStringBundle::GetStringByID(i, pBundle, *pStr);
}
else
--- a/mailnews/import/src/nsImportMail.cpp
+++ b/mailnews/import/src/nsImportMail.cpp
@@ -753,24 +753,16 @@ ImportMailThread( void *stuff)
nsCOMPtr<nsIMsgFolder> subFolder;
nsCOMPtr<nsISimpleEnumerator> enumerator;
PRBool exists;
nsString success;
nsString error;
- nsCOMPtr<nsIStringBundle> pBundle;
- rv = nsImportStringBundle::GetStringBundleProxy(pData->stringBundle, getter_AddRefs(pBundle));
- if (NS_FAILED(rv))
- {
- IMPORT_LOG0("*** ImportMailThread: Unable to obtain proxy string service for the import.");
- pData->abort = PR_TRUE;
- }
-
// Initialize the curFolder proxy object
nsCOMPtr<nsIProxyObjectManager> proxyObjMgr =
do_GetService(NS_XPCOMPROXY_CONTRACTID, &rv);
if (NS_FAILED(rv))
{
IMPORT_LOG0("*** ImportMailThread: Unable to obtain proxy object manager for the import.");
pData->abort = PR_TRUE;
}
@@ -808,60 +800,64 @@ ImportMailThread( void *stuff)
rv = box->GetDepth( &newDepth);
if (newDepth > depth) {
// OK, we are going to add a subfolder under the last/previous folder we processed, so
// find this folder (stored in 'lastName') who is going to be the new parent folder.
IMPORT_LOG1("ImportMailThread: Processing child folder '%s'.", NS_ConvertUTF16toUTF8(lastName).get());
rv = curProxy->GetChildNamed( lastName, getter_AddRefs( subFolder));
if (NS_FAILED( rv)) {
IMPORT_LOG1("*** ImportMailThread: Failed to get the interface for child folder '%s'.", NS_ConvertUTF16toUTF8(lastName).get());
- nsImportGenericMail::ReportError(IMPORT_ERROR_MB_FINDCHILD, lastName.get(), &error, pBundle);
+ nsImportGenericMail::ReportError(IMPORT_ERROR_MB_FINDCHILD,
+ lastName.get(),
+ &error, pData->stringBundle);
pData->fatalError = PR_TRUE;
break;
}
rv = proxyObjMgr->GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
NS_GET_IID(nsIMsgFolder),
subFolder,
NS_PROXY_SYNC | NS_PROXY_ALWAYS,
getter_AddRefs(curProxy));
if (NS_FAILED( rv)) {
IMPORT_LOG1("*** ImportMailThread: Failed to get the proxy interface for child folder '%s'.", NS_ConvertUTF16toUTF8(lastName).get());
- nsImportStringBundle::GetStringByID(IMPORT_ERROR_MB_NOPROXY, pBundle,
- error);
+ nsImportStringBundle::GetStringByID(IMPORT_ERROR_MB_NOPROXY, pData->stringBundle,
+ error);
pData->fatalError = PR_TRUE;
break;
}
// Make sure this new parent folder obj has the correct subfolder list so far.
rv = curProxy->GetSubFolders(getter_AddRefs(enumerator));
}
else if (newDepth < depth) {
rv = NS_OK;
while ((newDepth < depth) && NS_SUCCEEDED( rv)) {
nsCOMPtr<nsIMsgFolder> parFolder;
rv = curProxy->GetParent( getter_AddRefs( parFolder));
if (NS_FAILED( rv)) {
IMPORT_LOG1("*** ImportMailThread: Failed to get the interface for parent folder '%s'.", lastName.get());
- nsImportGenericMail::ReportError(IMPORT_ERROR_MB_FINDCHILD, lastName.get(), &error, pBundle);
+ nsImportGenericMail::ReportError(IMPORT_ERROR_MB_FINDCHILD,
+ lastName.get(), &error,
+ pData->stringBundle);
pData->fatalError = PR_TRUE;
break;
}
rv = proxyObjMgr->GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
NS_GET_IID(nsIMsgFolder),
parFolder,
NS_PROXY_SYNC | NS_PROXY_ALWAYS,
getter_AddRefs(curProxy));
depth--;
}
if (NS_FAILED( rv)) {
IMPORT_LOG1("*** ImportMailThread: Failed to get the proxy interface for parent folder '%s'.", lastName.get());
- nsImportStringBundle::GetStringByID(IMPORT_ERROR_MB_NOPROXY, pBundle,
- error);
+ nsImportStringBundle::GetStringByID(IMPORT_ERROR_MB_NOPROXY,
+ pData->stringBundle, error);
pData->fatalError = PR_TRUE;
break;
}
}
depth = newDepth;
pName = nsnull;
box->GetDisplayName( &pName);
if (pName) {
@@ -895,17 +891,18 @@ ImportMailThread( void *stuff)
rv = curProxy->GetChildNamed(lastName, getter_AddRefs(newFolder));
if (NS_SUCCEEDED(rv))
newFolder->GetFilePath(getter_AddRefs(outBox));
else
IMPORT_LOG1("*** ImportMailThread: Failed to locate subfolder '%s' after it's been created.", lastName.get());
if (NS_FAILED( rv)) {
- nsImportGenericMail::ReportError(IMPORT_ERROR_MB_CREATE, lastName.get(), &error, pBundle);
+ nsImportGenericMail::ReportError(IMPORT_ERROR_MB_CREATE, lastName.get(),
+ &error, pData->stringBundle);
}
if (size && import && newFolder && outBox && NS_SUCCEEDED( rv)) {
PRBool fatalError = PR_FALSE;
pData->currentSize = size;
PRUnichar *pSuccess = nsnull;
PRUnichar *pError = nsnull;
rv = pData->mailImport->ImportMailbox( box, outBox, &pError, &pSuccess, &fatalError);
--- a/mailnews/import/src/nsImportService.cpp
+++ b/mailnews/import/src/nsImportService.cpp
@@ -57,16 +57,19 @@
#include "nsImportABDescriptor.h"
#include "nsIImportGeneric.h"
#include "nsImportFieldMap.h"
#include "nsICategoryManager.h"
#include "nsXPCOM.h"
#include "nsISupportsPrimitives.h"
#include "plstr.h"
#include "prmem.h"
+#include "nsMsgCompCID.h"
+#include "nsThreadUtils.h"
+#include "nsIEditor.h"
#include "ImportDebug.h"
#include "nsImportService.h"
#include "nsImportStringBundle.h"
#include "nsCRTGlue.h"
#include "nsServiceManagerUtils.h"
#include "nsComponentManagerUtils.h"
PRLogModuleInfo *IMPORTLOGMODULE = nsnull;
@@ -308,17 +311,92 @@ NS_IMETHODIMP nsImportService::GetModule
else
count++;
}
}
return( NS_ERROR_FAILURE);
}
+class nsProxySendRunnable : public nsRunnable
+{
+public:
+ nsProxySendRunnable(nsIEditor *aEditor, nsIMsgIdentity *aIdentity,
+ nsIMsgCompFields *aMsgFields,
+ nsMsgDeliverMode aDeliverMode,
+ const char *attachment1_type,
+ const char *attachment1_body,
+ PRUint32 attachment1_body_length,
+ const nsMsgAttachedFile *loaded_attachments,
+ nsIMsgSendListener *aListener);
+ NS_DECL_NSIRUNNABLE
+private:
+ nsCOMPtr<nsIEditor> m_editor;
+ nsCOMPtr<nsIMsgIdentity> m_identity;
+ nsCOMPtr<nsIMsgCompFields> m_compFields;
+ nsMsgDeliverMode m_deliverMode;
+ nsCString m_bodyType;
+ nsCString m_body;
+ PRUint32 m_bodyLength;
+ const nsMsgAttachedFile *m_loadedAttachments;
+ nsCOMPtr<nsIMsgSendListener> m_listener;
+};
+
+nsProxySendRunnable::nsProxySendRunnable(nsIEditor *aEditor, nsIMsgIdentity *aIdentity,
+ nsIMsgCompFields *aMsgFields,
+ nsMsgDeliverMode aDeliverMode,
+ const char *aBodyType,
+ const char *aBody,
+ PRUint32 aBodyLength,
+ const nsMsgAttachedFile *aLoadedAttachments,
+ nsIMsgSendListener *aListener) :
+ m_editor(aEditor), m_identity(aIdentity), m_compFields(aMsgFields),
+ m_deliverMode(aDeliverMode), m_bodyType(aBodyType),
+ m_body(aBody), m_bodyLength(aBodyLength), m_loadedAttachments(aLoadedAttachments),
+ m_listener(aListener)
+{
+}
+
+NS_IMETHODIMP nsProxySendRunnable::Run()
+{
+ nsresult rv;
+ nsCOMPtr<nsIMsgSend> msgSend = do_CreateInstance(NS_MSGSEND_CONTRACTID, &rv);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ return msgSend->CreateAndSendMessage(m_editor, m_identity, nsnull, m_compFields,
+ PR_FALSE, PR_TRUE,
+ m_deliverMode, nsnull, m_bodyType.get(), m_body.get(),
+ m_bodyLength, nsnull, m_loadedAttachments,
+ nsnull, nsnull, nsnull, m_listener, nsnull,
+ EmptyCString(), nsnull);
+}
+
+
+NS_IMETHODIMP nsImportService::ProxySend(nsIEditor *aEditor, nsIMsgIdentity *aIdentity,
+ nsIMsgCompFields *aMsgFields,
+ nsMsgDeliverMode aDeliverMode,
+ const char *attachment1_type,
+ const char *attachment1_body,
+ PRUint32 attachment1_body_length,
+ const nsMsgAttachedFile *loaded_attachments,
+ nsIMsgSendListener *aListener)
+{
+ nsRefPtr<nsProxySendRunnable> runnable =
+ new nsProxySendRunnable(aEditor, aIdentity,
+ aMsgFields,
+ aDeliverMode,
+ attachment1_type,
+ attachment1_body,
+ attachment1_body_length,
+ loaded_attachments,
+ aListener);
+ // invoke the callback
+ return NS_DispatchToMainThread(runnable);
+}
NS_IMETHODIMP nsImportService::GetModule( const char *filter, PRInt32 index, nsIImportModule **_retval)
{
NS_PRECONDITION(_retval != nsnull, "null ptr");
if (!_retval)
return NS_ERROR_NULL_POINTER;
*_retval = nsnull;
@@ -526,8 +604,9 @@ void nsImportModuleList::AddModule( cons
m_pList[m_count]->SetName( pName);
m_pList[m_count]->SetDescription( pDesc);
m_count++;
#ifdef IMPORT_DEBUG
IMPORT_LOG3( "* nsImportService registered import module: %s, %s, %s\n", NS_LossyConvertUTF16toASCII(pName).get(), NS_LossyConvertUTF16toASCII(pDesc).get(), pSupports);
#endif
}
+
--- a/mailnews/import/src/nsImportStringBundle.cpp
+++ b/mailnews/import/src/nsImportStringBundle.cpp
@@ -39,48 +39,31 @@
#include "nsCOMPtr.h"
#include "nsIStringBundle.h"
#include "nsImportStringBundle.h"
#include "nsIServiceManager.h"
#include "nsIProxyObjectManager.h"
#include "nsIURI.h"
#include "nsServiceManagerUtils.h"
#include "nsComponentManagerUtils.h"
-#include "nsXPCOMCIDInternal.h"
nsresult nsImportStringBundle::GetStringBundle(const char *aPropertyURL,
nsIStringBundle **aBundle)
{
nsresult rv;
nsCOMPtr<nsIStringBundleService> sBundleService =
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv) && (nsnull != sBundleService)) {
rv = sBundleService->CreateBundle(aPropertyURL, aBundle);
}
return rv;
}
-nsresult nsImportStringBundle::GetStringBundleProxy(nsIStringBundle *aOriginalBundle,
- nsIStringBundle **aProxy)
-{
- nsresult rv;
- nsCOMPtr<nsIProxyObjectManager> proxyObjMgr =
- do_GetService(NS_XPCOMPROXY_CONTRACTID, &rv);
- NS_ENSURE_SUCCESS(rv, rv);
-
- // create a proxy object if we aren't on the same thread?
- return proxyObjMgr->GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
- NS_GET_IID(nsIStringBundle),
- aOriginalBundle,
- NS_PROXY_SYNC | NS_PROXY_ALWAYS,
- (void **) aProxy);
-}
-
void nsImportStringBundle::GetStringByID(PRInt32 aStringID,
nsIStringBundle *aBundle,
nsString &aResult)
{
aResult.Adopt(GetStringByID(aStringID, aBundle));
}
PRUnichar *nsImportStringBundle::GetStringByID(PRInt32 aStringID,
--- a/mailnews/import/src/nsImportStringBundle.h
+++ b/mailnews/import/src/nsImportStringBundle.h
@@ -51,18 +51,16 @@ public:
nsString &aResult);
static PRUnichar* GetStringByName(const char *aName,
nsIStringBundle *aBundle = nsnull);
static void GetStringByName(const char *aName,
nsIStringBundle *aBundle,
nsString &aResult);
static nsresult GetStringBundle(const char *aPropertyURL,
nsIStringBundle **aBundle);
- static nsresult GetStringBundleProxy(nsIStringBundle *aOriginalBundle,
- nsIStringBundle **aProxy);
};
#define IMPORT_MSGS_URL "chrome://messenger/locale/importMsgs.properties"
#define IMPORT_NO_ADDRBOOKS 2000
#define IMPORT_ERROR_AB_NOTINITIALIZED 2001
#define IMPORT_ERROR_AB_NOTHREAD 2002
--- a/mailnews/import/text/src/nsTextImport.cpp
+++ b/mailnews/import/text/src/nsTextImport.cpp
@@ -262,23 +262,17 @@ NS_IMETHODIMP ImportAddressImpl::GetAuto
return NS_ERROR_NULL_POINTER;
nsString str;
*_retval = PR_FALSE;
if (!m_notProxyBundle)
return NS_ERROR_FAILURE;
- nsCOMPtr<nsIStringBundle> proxy;
- nsresult rv =
- nsImportStringBundle::GetStringBundleProxy(m_notProxyBundle,
- getter_AddRefs(proxy));
- NS_ENSURE_SUCCESS(rv, rv);
-
- nsImportStringBundle::GetStringByID(TEXTIMPORT_ADDRESS_NAME, proxy, str);
+ nsImportStringBundle::GetStringByID(TEXTIMPORT_ADDRESS_NAME, m_notProxyBundle, str);
*addrDescription = ToNewUnicode(str);
return( NS_OK);
}
NS_IMETHODIMP ImportAddressImpl::GetDefaultLocation(nsIFile **ppLoc, PRBool *found, PRBool *userVerify)
{
NS_PRECONDITION(found != nsnull, "null ptr");
@@ -425,29 +419,23 @@ ImportAddressImpl::ImportAddressBook(nsI
PRUnichar ** pErrorLog,
PRUnichar ** pSuccessLog,
PRBool * fatalError)
{
NS_PRECONDITION(pSource != nsnull, "null ptr");
NS_PRECONDITION(pDestination != nsnull, "null ptr");
NS_PRECONDITION(fatalError != nsnull, "null ptr");
- nsCOMPtr<nsIStringBundle> pBundle;
- nsresult rv =
- nsImportStringBundle::GetStringBundleProxy(m_notProxyBundle,
- getter_AddRefs(pBundle));
- NS_ENSURE_SUCCESS(rv, rv);
-
m_bytesImported = 0;
nsString success, error;
if (!pSource || !pDestination || !fatalError) {
IMPORT_LOG0( "*** Bad param passed to text address import\n");
nsImportStringBundle::GetStringByID(TEXTIMPORT_ADDRESS_BADPARAM,
- pBundle,
+ m_notProxyBundle,
error);
SetLogs(success, error, pErrorLog, pSuccessLog);
if (fatalError)
*fatalError = PR_TRUE;
return NS_ERROR_NULL_POINTER;
@@ -458,66 +446,67 @@ ImportAddressImpl::ImportAddressBook(nsI
PRBool addrAbort = PR_FALSE;
nsString name;
pSource->GetPreferredName(name);
PRUint32 addressSize = 0;
pSource->GetSize( &addressSize);
if (addressSize == 0) {
IMPORT_LOG0( "Address book size is 0, skipping import.\n");
- ReportSuccess(name, &success, pBundle);
+ ReportSuccess(name, &success, m_notProxyBundle);
SetLogs(success, error, pErrorLog, pSuccessLog);
return NS_OK;
}
nsCOMPtr<nsIFile> inFile;
if (NS_FAILED(pSource->GetAbFile(getter_AddRefs(inFile)))) {
- ReportError(TEXTIMPORT_ADDRESS_BADSOURCEFILE, name, &error, pBundle);
+ ReportError(TEXTIMPORT_ADDRESS_BADSOURCEFILE, name, &error, m_notProxyBundle);
SetLogs(success, error, pErrorLog, pSuccessLog);
return NS_ERROR_FAILURE;
}
if (!aSupportService) {
IMPORT_LOG0("Missing support service to import call");
return NS_ERROR_FAILURE;
}
PRBool isLDIF = PR_FALSE;
+ nsresult rv;
nsCOMPtr<nsIAbLDIFService> ldifService(do_QueryInterface(aSupportService, &rv));
if (NS_SUCCEEDED(rv)) {
rv = ldifService->IsLDIFFile(inFile, &isLDIF);
if (NS_FAILED(rv)) {
IMPORT_LOG0( "*** Error reading address file\n");
}
}
if (NS_FAILED( rv)) {
- ReportError(TEXTIMPORT_ADDRESS_CONVERTERROR, name, &error, pBundle);
+ ReportError(TEXTIMPORT_ADDRESS_CONVERTERROR, name, &error, m_notProxyBundle);
SetLogs(success, error, pErrorLog, pSuccessLog);
return( rv);
}
if (isLDIF) {
if (ldifService)
rv = ldifService->ImportLDIFFile(pDestination, inFile, PR_FALSE, &m_bytesImported);
else
return NS_ERROR_FAILURE;
}
else {
rv = m_text.ImportAddresses( &addrAbort, name.get(), inFile, pDestination, fieldMap, error, &m_bytesImported);
SaveFieldMap( fieldMap);
}
if (NS_SUCCEEDED( rv) && error.IsEmpty()) {
- ReportSuccess(name, &success, pBundle);
+ ReportSuccess(name, &success, m_notProxyBundle);
SetLogs(success, error, pErrorLog, pSuccessLog);
}
else {
- ReportError(TEXTIMPORT_ADDRESS_CONVERTERROR, name, &error, pBundle);
+ ReportError(TEXTIMPORT_ADDRESS_CONVERTERROR, name, &error, m_notProxyBundle);
SetLogs(success, error, pErrorLog, pSuccessLog);
}
IMPORT_LOG0( "*** Text address import done\n");
return rv;
}
--- a/mailnews/import/vcard/src/nsVCardImport.cpp
+++ b/mailnews/import/vcard/src/nsVCardImport.cpp
@@ -233,22 +233,17 @@ NS_IMETHODIMP ImportVCardAddressImpl::Ge
NS_ENSURE_ARG_POINTER(_retval);
nsString str;
*_retval = PR_FALSE;
if (!m_notProxyBundle)
return NS_ERROR_FAILURE;
- nsCOMPtr<nsIStringBundle> proxy;
- nsresult rv = nsImportStringBundle::GetStringBundleProxy(
- m_notProxyBundle, getter_AddRefs(proxy));
- NS_ENSURE_SUCCESS(rv, rv);
-
- nsImportStringBundle::GetStringByName("vCardImportAddressName", proxy, str);
+ nsImportStringBundle::GetStringByName("vCardImportAddressName", m_notProxyBundle, str);
*addrDescription = ToNewUnicode(str);
return NS_OK;
}
NS_IMETHODIMP ImportVCardAddressImpl::GetDefaultLocation(
nsIFile **ppLoc, PRBool *found, PRBool *userVerify)
{
NS_ENSURE_ARG_POINTER(found);
@@ -382,57 +377,52 @@ NS_IMETHODIMP ImportVCardAddressImpl::Im
{
NS_ENSURE_ARG_POINTER(pSource);
NS_ENSURE_ARG_POINTER(pDestination);
NS_ENSURE_ARG_POINTER(fatalError);
if (!m_notProxyBundle)
return NS_ERROR_FAILURE;
- nsCOMPtr<nsIStringBundle> proxy;
- nsresult rv = nsImportStringBundle::GetStringBundleProxy(
- m_notProxyBundle, getter_AddRefs(proxy));
- NS_ENSURE_SUCCESS(rv, rv);
-
m_bytesImported = 0;
nsString success, error;
PRBool addrAbort = PR_FALSE;
nsString name;
pSource->GetPreferredName(name);
PRUint32 addressSize = 0;
pSource->GetSize(&addressSize);
if (addressSize == 0) {
IMPORT_LOG0("Address book size is 0, skipping import.\n");
- ReportSuccess(name, &success, proxy);
+ ReportSuccess(name, &success, m_notProxyBundle);
SetLogs(success, error, pErrorLog, pSuccessLog);
return NS_OK;
}
nsCOMPtr<nsIFile> inFile;
if (NS_FAILED(pSource->GetAbFile(getter_AddRefs(inFile)))) {
- ReportError("vCardImportAddressBadSourceFile", name, &error, proxy);
+ ReportError("vCardImportAddressBadSourceFile", name, &error, m_notProxyBundle);
SetLogs(success, error, pErrorLog, pSuccessLog);
return NS_ERROR_FAILURE;
}
if (!aSupportService) {
IMPORT_LOG0("Missing support service to import call\n");
return NS_ERROR_FAILURE;
}
- rv = m_vCard.ImportAddresses(
+ nsresult rv = m_vCard.ImportAddresses(
&addrAbort, name.get(), inFile, pDestination, error, &m_bytesImported);
if (NS_SUCCEEDED(rv) && error.IsEmpty()) {
- ReportSuccess(name, &success, proxy);
+ ReportSuccess(name, &success, m_notProxyBundle);
SetLogs(success, error, pErrorLog, pSuccessLog);
}
else {
- ReportError("vCardImportAddressConvertError", name, &error, proxy);
+ ReportError("vCardImportAddressConvertError", name, &error, m_notProxyBundle);
SetLogs(success, error, pErrorLog, pSuccessLog);
}
IMPORT_LOG0("*** VCard address import done\n");
return rv;
}
NS_IMETHODIMP ImportVCardAddressImpl::GetImportProgress(PRUint32 *_retval)
--- a/mailnews/import/winlivemail/nsWMImport.cpp
+++ b/mailnews/import/winlivemail/nsWMImport.cpp
@@ -235,39 +235,35 @@ void ImportWMMailImpl::AddLinebreak( nsS
pStream->Append( PRUnichar('\n'));
}
void ImportWMMailImpl::ReportSuccess( nsString& name, PRInt32 count, nsString *pStream)
{
if (!pStream)
return;
// load the success string
- nsIStringBundle *pBundle = nsWMStringBundle::GetStringBundleProxy();
- PRUnichar *pFmt = nsWMStringBundle::GetStringByID( WMIMPORT_MAILBOX_SUCCESS, pBundle);
+ PRUnichar *pFmt = nsWMStringBundle::GetStringByID( WMIMPORT_MAILBOX_SUCCESS);
PRUnichar *pText = nsTextFormatter::smprintf( pFmt, name.get(), count);
pStream->Append( pText);
nsTextFormatter::smprintf_free( pText);
nsWMStringBundle::FreeString( pFmt);
AddLinebreak( pStream);
- NS_IF_RELEASE( pBundle);
}
void ImportWMMailImpl::ReportError( PRInt32 errorNum, nsString& name, nsString *pStream)
{
if (!pStream)
return;
// load the error string
- nsIStringBundle *pBundle = nsWMStringBundle::GetStringBundleProxy();
- PRUnichar *pFmt = nsWMStringBundle::GetStringByID( errorNum, pBundle);
+ PRUnichar *pFmt = nsWMStringBundle::GetStringByID( errorNum);
PRUnichar *pText = nsTextFormatter::smprintf( pFmt, name.get());
pStream->Append( pText);
nsTextFormatter::smprintf_free( pText);
nsWMStringBundle::FreeString( pFmt);
AddLinebreak( pStream);
- NS_IF_RELEASE( pBundle);
}
void ImportWMMailImpl::SetLogs(nsString& success, nsString& error,
PRUnichar **pError, PRUnichar **pSuccess)
{
if (pError)
*pError = ToNewUnicode(error);
if (pSuccess)
--- a/mailnews/import/winlivemail/nsWMStringBundle.cpp
+++ b/mailnews/import/winlivemail/nsWMStringBundle.cpp
@@ -36,75 +36,57 @@
* ***** END LICENSE BLOCK ***** */
#include "prprf.h"
#include "prmem.h"
#include "nsCOMPtr.h"
#include "nsReadableUtils.h"
#include "nsIStringBundle.h"
#include "nsWMStringBundle.h"
#include "nsIServiceManager.h"
-#include "nsIProxyObjectManager.h"
#include "nsIURI.h"
#define WM_MSGS_URL "chrome://messenger/locale/wmImportMsgs.properties"
nsIStringBundle * nsWMStringBundle::m_pBundle = nsnull;
nsIStringBundle *nsWMStringBundle::GetStringBundle( void)
{
if (m_pBundle)
return( m_pBundle);
nsresult rv;
char* propertyURL = WM_MSGS_URL;
nsIStringBundle* sBundle = nsnull;
-
nsCOMPtr<nsIStringBundleService> sBundleService =
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv) && (nsnull != sBundleService)) {
rv = sBundleService->CreateBundle(propertyURL, &sBundle);
}
m_pBundle = sBundle;
return( sBundle);
}
-nsIStringBundle *nsWMStringBundle::GetStringBundleProxy( void)
+void nsWMStringBundle::GetStringByID( PRInt32 stringID, nsString& result)
{
- if (!m_pBundle)
- return( nsnull);
-
- nsIStringBundle *strProxy = nsnull;
- // create a proxy object if we aren't on the same thread?
- NS_GetProxyForObject(NS_PROXY_TO_MAIN_THREAD, NS_GET_IID(nsIStringBundle),
- m_pBundle, NS_PROXY_SYNC | NS_PROXY_ALWAYS,
- (void **) &strProxy);
-
- return( strProxy);
-}
-
-void nsWMStringBundle::GetStringByID( PRInt32 stringID, nsString& result, nsIStringBundle *pBundle)
-{
-
- PRUnichar *ptrv = GetStringByID( stringID, pBundle);
+ PRUnichar *ptrv = GetStringByID(stringID);
result = ptrv;
FreeString( ptrv);
}
-PRUnichar *nsWMStringBundle::GetStringByID(PRInt32 stringID, nsIStringBundle *pBundle)
+PRUnichar *nsWMStringBundle::GetStringByID(PRInt32 stringID)
{
- if (!pBundle) {
- pBundle = GetStringBundle();
- }
+ if (!m_pBundle)
+ m_pBundle = GetStringBundle();
- if (pBundle) {
+ if (m_pBundle) {
PRUnichar *ptrv = nsnull;
- nsresult rv = pBundle->GetStringFromID(stringID, &ptrv);
+ nsresult rv = m_pBundle->GetStringFromID(stringID, &ptrv);
if (NS_SUCCEEDED( rv) && ptrv)
return( ptrv);
}
nsString resultString;
resultString.AppendLiteral("[StringID ");
resultString.AppendInt(stringID);
--- a/mailnews/import/winlivemail/nsWMStringBundle.h
+++ b/mailnews/import/winlivemail/nsWMStringBundle.h
@@ -38,22 +38,21 @@
#define _nsWMStringBundle_H__
#include "nsString.h"
class nsIStringBundle;
class nsWMStringBundle {
public:
- static PRUnichar * GetStringByID(PRInt32 stringID, nsIStringBundle *pBundle = nsnull);
- static void GetStringByID(PRInt32 stringID, nsString& result, nsIStringBundle *pBundle = nsnull);
+ static PRUnichar * GetStringByID(PRInt32 stringID);
+ static void GetStringByID(PRInt32 stringID, nsString& result);
static nsIStringBundle * GetStringBundle( void); // don't release
static void FreeString( PRUnichar *pStr) { NS_Free( pStr);}
static void Cleanup( void);
- static nsIStringBundle * GetStringBundleProxy( void); // release
private:
static nsIStringBundle * m_pBundle;
};
#define WMIMPORT_NAME 2000