зеркало из https://github.com/mozilla/pjs.git
fix importing of eudora messages with embedded content, patch by gwenger@qualcomm.com, r=bienvenu, sr=mscott, NOT PART OF FIREFOX, 368334
This commit is contained in:
Родитель
a2eb7564b0
Коммит
9d646edfe9
|
@ -58,6 +58,8 @@ REQUIRES = xpcom \
|
|||
msgcompose \
|
||||
msgbase \
|
||||
dom \
|
||||
content \
|
||||
editor \
|
||||
uriloader \
|
||||
mailnews \
|
||||
msgdb \
|
||||
|
@ -73,6 +75,7 @@ CPPSRCS = \
|
|||
nsEudoraImport.cpp \
|
||||
nsEudoraMailbox.cpp \
|
||||
nsEudoraSettings.cpp \
|
||||
nsEudoraEditor.cpp \
|
||||
nsEudoraCompose.cpp \
|
||||
nsEudoraAddress.cpp \
|
||||
$(NULL)
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Geoffrey C. Wenger (gwenger@qualcomm.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
|
@ -63,12 +64,14 @@
|
|||
#include "nsNetCID.h"
|
||||
|
||||
#include "nsEudoraCompose.h"
|
||||
#include "nsEudoraEditor.h"
|
||||
|
||||
#include "EudoraDebugLog.h"
|
||||
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsMsgUtils.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
||||
static NS_DEFINE_CID( kMsgSendCID, NS_MSGSEND_CID);
|
||||
static NS_DEFINE_CID( kMsgCompFieldsCID, NS_MSGCOMPFIELDS_CID);
|
||||
|
@ -603,7 +606,7 @@ nsMsgAttachedFile * nsEudoraCompose::GetLocalAttachments( void)
|
|||
}
|
||||
|
||||
// Test a message send????
|
||||
nsresult nsEudoraCompose::SendTheMessage( nsIFile **pMsg)
|
||||
nsresult nsEudoraCompose::SendTheMessage(nsIFile *pMailImportLocation, nsIFile **pMsg)
|
||||
{
|
||||
nsresult rv = CreateComponents();
|
||||
if (NS_SUCCEEDED( rv))
|
||||
|
@ -713,53 +716,63 @@ nsresult nsEudoraCompose::SendTheMessage( nsIFile **pMsg)
|
|||
if ( from.IsEmpty() || to.IsEmpty() && cc.IsEmpty() && bcc.IsEmpty() )
|
||||
mode = nsIMsgSend::nsMsgSaveAsDraft;
|
||||
|
||||
// We only get the editor interface when there's embedded content.
|
||||
// Otherwise pEditor remains NULL. That way we only import with the pseudo
|
||||
// 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(
|
||||
nsnull, // no editor shell
|
||||
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
|
||||
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
|
||||
|
||||
}
|
||||
else {
|
||||
rv = m_pSendProxy->CreateAndSendMessage(
|
||||
nsnull, // no editor shell
|
||||
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
|
||||
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
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ public:
|
|||
nsEudoraCompose();
|
||||
~nsEudoraCompose();
|
||||
|
||||
nsresult SendTheMessage( nsIFile **pMsg);
|
||||
nsresult SendTheMessage(nsIFile *pMailImportLocation, nsIFile **pMsg);
|
||||
|
||||
void SetBody( const char *pBody, PRInt32 len, nsCString &bodyType) { m_pBody = pBody; m_bodyLen = len; m_bodyType = bodyType;}
|
||||
void SetHeaders( const char *pHeaders, PRInt32 len) { m_pHeaders = pHeaders; m_headerLen = len;}
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,88 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is qualcomm.com code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* QUALCOMM, Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2007
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Author: Geoffrey C. Wenger (gwenger@qualcomm.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* 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 "nscore.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIEditorMailSupport.h"
|
||||
#include "nsIDOMHTMLImageElement.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIFile.h"
|
||||
|
||||
|
||||
class nsEudoraEditor : public nsIEditor, public nsIEditorMailSupport
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIEDITOR
|
||||
NS_DECL_NSIEDITORMAILSUPPORT
|
||||
|
||||
nsEudoraEditor(const char * pBody, nsIFile * pMailImportLocation);
|
||||
|
||||
PRBool UpdateEmbeddedImageReference(PRUint32 aCIDHash, const nsAString & aOldRef, const nsAString & aUpdatedRef);
|
||||
|
||||
PRBool HasEmbeddedContent();
|
||||
|
||||
~nsEudoraEditor();
|
||||
|
||||
protected:
|
||||
NS_ConvertASCIItoUTF16 m_body;
|
||||
nsCOMPtr <nsIFile> m_pMailImportLocation;
|
||||
nsCOMPtr<nsISupportsArray> m_EmbeddedObjectList; // it's initialized when GetEmbeddedObjects is called
|
||||
};
|
||||
|
||||
|
||||
class nsEudoraHTMLImageElement : public nsIDOMHTMLImageElement
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOMNODE
|
||||
NS_DECL_NSIDOMELEMENT
|
||||
NS_DECL_NSIDOMHTMLELEMENT
|
||||
NS_DECL_NSIDOMHTMLIMAGEELEMENT
|
||||
|
||||
nsEudoraHTMLImageElement(nsEudoraEditor * pEditor, const nsAString & aSrc, PRUint32 aCIDHash);
|
||||
|
||||
private:
|
||||
~nsEudoraHTMLImageElement();
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIEditor> m_pEditor;
|
||||
nsString m_src;
|
||||
PRUint32 m_cidHash;
|
||||
};
|
|
@ -195,12 +195,12 @@ PRUint32 EudoraTOCEntry::GetMozillaStatus2Flags()
|
|||
|
||||
nsEudoraMailbox::nsEudoraMailbox()
|
||||
{
|
||||
m_fromLen = 0;
|
||||
m_fromLen = 0;
|
||||
}
|
||||
|
||||
nsEudoraMailbox::~nsEudoraMailbox()
|
||||
{
|
||||
EmptyAttachments();
|
||||
EmptyAttachments();
|
||||
}
|
||||
|
||||
nsresult nsEudoraMailbox::CreateTempFile( nsIFile **ppFile)
|
||||
|
@ -317,7 +317,6 @@ nsresult nsEudoraMailbox::ImportMailbox( PRUint32 *pBytes, PRBool *pAbort, const
|
|||
|
||||
if (NS_SUCCEEDED( rv ))
|
||||
{
|
||||
nsEudoraCompose compose;
|
||||
nsCString defaultDate;
|
||||
nsCAutoString bodyType;
|
||||
|
||||
|
@ -563,7 +562,7 @@ nsresult nsEudoraMailbox::ImportMessage(
|
|||
compose.SetDefaultDate(defaultDate);
|
||||
|
||||
nsCOMPtr <nsIFile> compositionFile;
|
||||
rv = compose.SendTheMessage(getter_AddRefs(compositionFile));
|
||||
rv = compose.SendTheMessage(m_mailImportLocation, getter_AddRefs(compositionFile));
|
||||
if (NS_SUCCEEDED( rv)) {
|
||||
nsCString fromLine(eudoraFromLine);
|
||||
SimpleBufferTonyRCopiedOnce copy;
|
||||
|
|
|
@ -212,6 +212,9 @@ private:
|
|||
static int IsWeekDayStr( const char *pStr);
|
||||
static int IsMonthStr( const char *pStr);
|
||||
|
||||
protected:
|
||||
nsCOMPtr <nsILocalFile> m_mailImportLocation;
|
||||
|
||||
private:
|
||||
PRInt64 m_mailSize;
|
||||
PRInt32 m_fromLen;
|
||||
|
|
|
@ -1062,7 +1062,7 @@ void nsEudoraWin32::GetMimeTypeFromExtension( nsCString& ext, nsCString& mimeTyp
|
|||
if (!pFile)
|
||||
return;
|
||||
|
||||
pFile->InitWithFile( m_mailImportLocation);
|
||||
pFile->InitWithFile(m_mailImportLocation);
|
||||
|
||||
pFile->AppendNative(NS_LITERAL_CSTRING("eudora.ini"));
|
||||
PRBool exists = PR_FALSE;
|
||||
|
|
|
@ -106,7 +106,6 @@ private:
|
|||
|
||||
private:
|
||||
PRUint32 m_depth;
|
||||
nsCOMPtr <nsILocalFile> m_mailImportLocation;
|
||||
nsCOMPtr <nsIFile> m_addressImportFolder;
|
||||
char * m_pMimeSection;
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче