Added Eudora mail import module

This commit is contained in:
tonyr%fbdesigns.com 1999-11-16 01:17:56 +00:00
parent b64383029b
commit f079a40fab
24 changed files with 4572 additions and 2 deletions

View File

@ -21,7 +21,7 @@
DEPTH=..\..
LocalDirs=public src resources
LocalDirs=public src resources eudora
!if "$(_MSC_VER)" == "1200"

View File

@ -0,0 +1,25 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH=..\..\..
DIRS=resources src
include <$(DEPTH)\config\rules.mak>

View File

@ -0,0 +1,55 @@
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#
#
# The following are used by the outlook express import code to display status/error
# and informational messages
#
# Short name of import module
## @name EUDORAIMPORT_NAME
## @loc None
2000=Eudora
# Description of import module
## @name EUDORAIMPORT_DESCRIPTION
## @loc None
2001=Eudora mail and address books
# Success message
## @name EUDORAIMPORT_MAILBOX_SUCCESS
## @loc None
2002=Mailbox %S, imported %d messages
# Error message
## @name EUDORAIMPORT_MAILBOX_BADPARAM
## @loc None
2003=Bad parameter passed to import mailbox.
# Error message
## @name EUDORAIMPORT_MAILBOX_BADSOURCEFILE
## @loc None
2004=Error accessing file for mailbox %S.
# Error message
## @name EUDORAIMPORT_MAILBOX_CONVERTERROR
## @loc None
2005=Error importing mailbox %S, all messages may not be imported from this mailbox.

View File

@ -0,0 +1,28 @@
#!nmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1999 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH=..\..\..\..\..\..
include <$(DEPTH)\config\rules.mak>
install::
$(MAKE_INSTALL) eudoraImportMsgs.properties $(DIST)\bin\chrome\messenger\locale\en-US
clobber::
rm -f $(DIST)bin\chrome\messenger\locale\en-US\eudoraImportMsgs.properties

View File

@ -0,0 +1,22 @@
#!nmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1999 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH=..\..\..\..\..
DIRS= en-US
include <$(DEPTH)\config\rules.mak>

View File

@ -0,0 +1,22 @@
#!nmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1999 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH=..\..\..\..
DIRS= locale
include <$(DEPTH)\config\rules.mak>

View File

@ -0,0 +1,45 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef EudoraDebugLog_h___
#define EudoraDebugLog_h___
#ifdef NS_DEBUG
#define IMPORT_DEBUG 1
#endif
#ifdef IMPORT_DEBUG
#include "stdio.h"
#define IMPORT_LOG0( x) printf( x)
#define IMPORT_LOG1( x, y) printf( x, y)
#define IMPORT_LOG2( x, y, z) printf( x, y, z)
#define IMPORT_LOG3( a, b, c, d) printf( a, b, c, d)
#else
#define IMPORT_LOG0( x)
#define IMPORT_LOG1( x, y)
#define IMPORT_LOG2( x, y, z)
#define IMPORT_LOG3( a, b, c, d)
#endif
#endif /* EudoraDebugLog_h___ */

View File

@ -0,0 +1,47 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH=..\..\..\..
MODULE=impEudra
MAKE_OBJ_TYPE=DLL
DLLNAME=$(MODULE)
DLL=.\$(OBJDIR)\$(DLLNAME).dll
CPP_OBJS=\
.\$(OBJDIR)\nsEudoraFactory.obj \
.\$(OBJDIR)\nsEudoraStringBundle.obj \
.\$(OBJDIR)\nsEudoraImport.obj \
.\$(OBJDIR)\nsEudoraMailbox.obj \
.\$(OBJDIR)\nsEudoraWin32.obj \
.\$(OBJDIR)\nsEudoraSettings.obj \
.\$(OBJDIR)\nsEudoraCompose.obj \
$(NULL)
LLIBS=\
$(DIST)\lib\xpcom.lib \
$(DIST)\lib\plc3.lib \
$(LIBNSPR) \
$(NULL)
include <$(DEPTH)\config\rules.mak>
install:: $(DLL)
$(MAKE_INSTALL) $(DLL) $(DIST)\bin\components

View File

@ -0,0 +1,533 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nscore.h"
#include "prthread.h"
#include "nsString.h"
#include "nsCOMPtr.h"
#include "nsIFileSpec.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsIIOService.h"
#include "nsIURI.h"
#include "nsMsgBaseCID.h"
#include "nsMsgCompCID.h"
#include "nsIMsgCompose.h"
#include "nsIMsgCompFields.h"
#include "nsIMsgSend.h"
#include "nsIMsgMailSession.h"
#include "nsIMsgAccountManager.h"
#include "nsEudoraCompose.h"
#include "EudoraDebugLog.h"
#include "nsMimeTypes.h"
#include "nsEudoraMailbox.h"
static NS_DEFINE_CID( kMsgSendCID, NS_MSGSEND_CID);
static NS_DEFINE_CID( kMsgCompFieldsCID, NS_MSGCOMPFIELDS_CID);
static NS_DEFINE_CID( kMsgMailSessionCID, NS_MSGMAILSESSION_CID);
static NS_DEFINE_CID( kIOServiceCID, NS_IOSERVICE_CID);
// We need to do some calculations to set these numbers to something reasonable!
// Unless of course, CreateAndSendMessage will NEVER EVER leave us in the lurch
#define kHungCount 100000
#define kHungAbortCount 1000
#ifdef IMPORT_DEBUG
char *p_test_headers =
"Received: from netppl.fi (IDENT:monitor@get.freebsd.because.microsoftsucks.net [209.3.31.115])\n\
by mail4.sirius.com (8.9.1/8.9.1) with SMTP id PAA27232;\n\
Mon, 17 May 1999 15:27:43 -0700 (PDT)\n\
Message-ID: <ikGD3jRTsKklU.Ggm2HmE2A1Jsqd0p@netppl.fi>\n\
From: \"adsales@qualityservice.com\" <adsales@qualityservice.com>\n\
Subject: Re: Your College Diploma (36822)\n\
Date: Mon, 17 May 1999 15:09:29 -0400 (EDT)\n\
MIME-Version: 1.0\n\
Content-Type: TEXT/PLAIN; charset=\"US-ASCII\"\n\
Content-Transfer-Encoding: 7bit\n\
X-UIDL: 19990517.152941\n\
Status: RO";
char *p_test_body =
"Hello world?\n\
";
#else
#define p_test_headers nsnull
#define p_test_body nsnull
#endif
#define kWhitespace "\b\t\r\n "
// First off, a listener
class SendListener : public nsIMsgSendListener
{
public:
SendListener() {
NS_INIT_REFCNT();
m_done = PR_FALSE;
m_location = nsnull;
}
virtual ~SendListener() { NS_IF_RELEASE( m_location); }
// nsISupports interface
NS_DECL_ISUPPORTS
/* void OnStartSending (in string aMsgID, in PRUint32 aMsgSize); */
NS_IMETHOD OnStartSending(const char *aMsgID, PRUint32 aMsgSize) {return NS_OK;}
/* void OnProgress (in string aMsgID, in PRUint32 aProgress, in PRUint32 aProgressMax); */
NS_IMETHOD OnProgress(const char *aMsgID, PRUint32 aProgress, PRUint32 aProgressMax) {return NS_OK;}
/* void OnStatus (in string aMsgID, in wstring aMsg); */
NS_IMETHOD OnStatus(const char *aMsgID, const PRUnichar *aMsg) {return NS_OK;}
/* void OnStopSending (in string aMsgID, in nsresult aStatus, in wstring aMsg, in nsIFileSpec returnFileSpec); */
NS_IMETHOD OnStopSending(const char *aMsgID, nsresult aStatus, const PRUnichar *aMsg,
nsIFileSpec *returnFileSpec) {
m_done = PR_TRUE;
m_location = returnFileSpec;
NS_IF_ADDREF( m_location);
return NS_OK;
}
static nsresult CreateSendListener( nsIMsgSendListener **ppListener);
void Reset() { m_done = PR_FALSE; NS_IF_RELEASE( m_location); m_location = nsnull;}
public:
PRBool m_done;
nsIFileSpec * m_location;
};
NS_IMPL_ISUPPORTS( SendListener, nsCOMTypeInfo<nsIMsgSendListener>::GetIID())
nsresult SendListener::CreateSendListener( nsIMsgSendListener **ppListener)
{
NS_PRECONDITION(ppListener != nsnull, "null ptr");
if (! ppListener)
return NS_ERROR_NULL_POINTER;
*ppListener = new SendListener();
if (! *ppListener)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*ppListener);
return NS_OK;
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
nsEudoraCompose::nsEudoraCompose()
{
m_pIOService = nsnull;
m_pAttachments = nsnull;
m_pListener = nsnull;
m_pMsgSend = nsnull;
m_pMsgFields = nsnull;
m_pIdentity = nsnull;
m_pHeaders = p_test_headers;
if (m_pHeaders)
m_headerLen = nsCRT::strlen( m_pHeaders);
else
m_headerLen = 0;
m_pBody = p_test_body;
if (m_pBody)
m_bodyLen = nsCRT::strlen( m_pBody);
else
m_bodyLen = 0;
}
nsEudoraCompose::~nsEudoraCompose()
{
NS_IF_RELEASE( m_pIOService);
NS_IF_RELEASE( m_pMsgSend);
NS_IF_RELEASE( m_pListener);
NS_IF_RELEASE( m_pMsgFields);
NS_IF_RELEASE( m_pIdentity);
}
nsresult nsEudoraCompose::CreateIdentity( void)
{
if (m_pIdentity)
return( NS_OK);
nsresult rv;
NS_WITH_SERVICE(nsIMsgMailSession, mailSession, kMsgMailSessionCID, &rv);
if (NS_FAILED(rv)) return( rv);
nsCOMPtr<nsIMsgAccountManager> accMgr;
rv = mailSession->GetAccountManager( getter_AddRefs( accMgr));
if (NS_FAILED( rv)) return( rv);
rv = accMgr->CreateIdentity( &m_pIdentity);
if (m_pIdentity) {
m_pIdentity->SetFullName( "Import Identity");
m_pIdentity->SetIdentityName( "Import Identity");
m_pIdentity->SetEmail( "import@import.service");
}
return( rv);
}
nsresult nsEudoraCompose::CreateComponents( void)
{
nsresult rv = NS_OK;
if (!m_pIOService) {
IMPORT_LOG0( "Creating nsIOService\n");
NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &rv);
if (NS_FAILED(rv))
return( rv);
m_pIOService = service;
NS_IF_ADDREF( m_pIOService);
}
NS_IF_RELEASE( m_pMsgFields);
if (!m_pMsgSend)
rv = nsComponentManager::CreateInstance( kMsgSendCID, nsnull, nsCOMTypeInfo<nsIMsgSend>::GetIID(), (void **) &m_pMsgSend);
if (!m_pListener && NS_SUCCEEDED( rv)) {
rv = SendListener::CreateSendListener( &m_pListener);
if (NS_SUCCEEDED( rv)) {
rv = m_pMsgSend->AddListener( m_pListener);
if (NS_FAILED( rv)) {
NS_IF_RELEASE( m_pListener);
m_pListener = nsnull;
}
}
}
if (NS_SUCCEEDED(rv) && m_pMsgSend) {
rv = nsComponentManager::CreateInstance( kMsgCompFieldsCID, nsnull, nsCOMTypeInfo<nsIMsgCompFields>::GetIID(), (void **) &m_pMsgFields);
if (NS_SUCCEEDED(rv) && m_pMsgFields)
return( NS_OK);
}
return( NS_ERROR_FAILURE);
}
void nsEudoraCompose::GetHeaderValue( const char *pHeader, nsString& val)
{
val.Truncate();
if (!m_pHeaders)
return;
PRInt32 start = 0;
PRInt32 len = nsCRT::strlen( pHeader);
const char *pChar = m_pHeaders;
if (!nsCRT::strncasecmp( pHeader, m_pHeaders, len)) {
start = len;
}
else {
while (start < m_headerLen) {
while ((start < m_headerLen) && (*pChar != 0x0D) && (*pChar != 0x0A)) {
start++;
pChar++;
}
while ((start < m_headerLen) && ((*pChar == 0x0D) || (*pChar == 0x0A))) {
start++;
pChar++;
}
if ((start < m_headerLen) && !nsCRT::strncasecmp( pChar, pHeader, len))
break;
}
if (start < m_headerLen)
start += len;
}
if (start >= m_headerLen)
return;
PRInt32 end = start;
pChar = m_pHeaders + start;
while (end < m_headerLen) {
while ((end < m_headerLen) && (*pChar != 0x0D) && (*pChar != 0x0A)) {
end++;
pChar++;
}
if (end > start) {
val.Append( m_pHeaders + start, end - start);
}
while ((end < m_headerLen) && ((*pChar == 0x0D) || (*pChar == 0x0A))) {
end++;
pChar++;
}
start = end;
while ((end < m_headerLen) && ((*pChar == ' ') || (*pChar == '\t'))) {
end++;
pChar++;
}
if (start == end)
break;
start = end;
val.Append( ' ');
}
val.Trim( kWhitespace);
}
void nsEudoraCompose::ExtractCharset( nsString& str)
{
nsString tStr;
PRInt32 idx = str.Find( "charset=", PR_TRUE);
if (idx != -1) {
idx += 8;
str.Right( tStr, str.Length() - idx);
idx = tStr.FindChar( ';');
if (idx != -1)
tStr.Left( str, idx);
else
str = tStr;
str.Trim( kWhitespace);
if ((str.CharAt( 0) == '"') && (str.Length() > 2)) {
str.Mid( tStr, 1, str.Length() - 2);
str = tStr;
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;
}
str.Trim( kWhitespace);
if ((str.CharAt( 0) == '"') && (str.Length() > 2)) {
str.Mid( tStr, 1, str.Length() - 2);
str = tStr;
str.Trim( kWhitespace);
}
// if multipart then ignore it since no eudora message body is ever
// valid multipart!
if (str.Length() > 10) {
str.Left( tStr, 10);
if (!tStr.Compare( "multipart/", PR_TRUE))
str.Truncate();
}
}
void nsEudoraCompose::CleanUpAttach( nsMsgAttachedFile *a, PRInt32 count)
{
for (PRInt32 i = 0; i < count; i++) {
NS_IF_RELEASE( a[i].orig_url);
if (a[i].type)
nsCRT::free( a[i].type);
if (a[i].description)
nsCRT::free( a[i].description);
if (a[i].encoding)
nsCRT::free( a[i].encoding);
}
delete [] a;
}
nsMsgAttachedFile * nsEudoraCompose::GetLocalAttachments( void)
{
/*
nsIURI *url = nsnull;
*/
PRInt32 count = 0;
if (m_pAttachments)
count = m_pAttachments->Count();
if (!count)
return( nsnull);
nsMsgAttachedFile *a = (nsMsgAttachedFile *) new nsMsgAttachedFile[count + 1];
if (!a)
return( nsnull);
nsCRT::memset(a, 0, sizeof(nsMsgAttachedFile) * (count + 1));
nsresult rv;
char * urlStr;
EudoraAttachment *pAttach;
for (PRInt32 i = 0; i < count; i++) {
// nsMsgNewURL(&url, "file://C:/boxster.jpg");
// a[i].orig_url = url;
// NS_PRECONDITION( PR_FALSE, "Forced Break");
pAttach = (EudoraAttachment *) m_pAttachments->ElementAt( i);
a[i].file_spec = new nsFileSpec;
pAttach->pAttachment->GetFileSpec( a[i].file_spec);
urlStr = nsnull;
pAttach->pAttachment->GetURLString( &urlStr);
if (!urlStr) {
CleanUpAttach( a, count);
return( nsnull);
}
rv = m_pIOService->NewURI( urlStr, nsnull, &(a[i].orig_url));
nsCRT::free( urlStr);
if (NS_FAILED( rv)) {
CleanUpAttach( a, count);
return( nsnull);
}
a[i].type = nsCRT::strdup( pAttach->mimeType);
a[i].description = nsCRT::strdup( pAttach->description);
a[i].encoding = nsCRT::strdup( ENCODING_BINARY);
}
return( a);
}
// Test a message send????
nsresult nsEudoraCompose::SendMessage( nsIFileSpec *pMsg)
{
nsresult rv = CreateComponents();
if (NS_SUCCEEDED( rv))
rv = CreateIdentity();
if (NS_FAILED( rv))
return( rv);
IMPORT_LOG0( "Eudora Compose created necessary components\n");
nsString bodyType;
nsString charSet;
nsString headerVal;
GetHeaderValue( "From:", headerVal);
if (headerVal.Length())
m_pMsgFields->SetFrom( headerVal.GetUnicode());
GetHeaderValue( "To:", headerVal);
if (headerVal.Length())
m_pMsgFields->SetTo( headerVal.GetUnicode());
GetHeaderValue( "Subject:", headerVal);
if (headerVal.Length())
m_pMsgFields->SetSubject( headerVal.GetUnicode());
GetHeaderValue( "Content-type:", headerVal);
bodyType = headerVal;
ExtractType( bodyType);
ExtractCharset( headerVal);
charSet = headerVal;
if (headerVal.Length())
m_pMsgFields->SetCharacterSet( headerVal.GetUnicode());
GetHeaderValue( "CC:", headerVal);
if (headerVal.Length())
m_pMsgFields->SetCc( headerVal.GetUnicode());
GetHeaderValue( "Message-ID:", headerVal);
if (headerVal.Length())
m_pMsgFields->SetMessageId( headerVal.GetUnicode());
GetHeaderValue( "Reply-To:", headerVal);
if (headerVal.Length())
m_pMsgFields->SetReplyTo( headerVal.GetUnicode());
// what about all of the other headers?!?!?!?!?!?!
char *pMimeType = nsnull;
if (bodyType.Length())
pMimeType = bodyType.ToNewCString();
IMPORT_LOG0( "Eudora compose calling CreateAndSendMessage\n");
nsMsgAttachedFile *pAttach = GetLocalAttachments();
rv = m_pMsgSend->CreateAndSendMessage( nsnull, // no editor shell
m_pIdentity, // dummy identity
m_pMsgFields, // message fields
PR_FALSE, // digest = NO
PR_TRUE, // dont_deliver = YES, make a file
nsMsgDeliverNow, // 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); // listener array
if (pAttach)
delete [] pAttach;
SendListener *pListen = (SendListener *)m_pListener;
if (NS_FAILED( rv)) {
IMPORT_LOG1( "*** Error, CreateAndSendMessage FAILED: 0x%lx\n", rv);
IMPORT_LOG1( "Headers: %s\n", m_pHeaders);
}
else {
// wait for the listener to get done!
PRInt32 abortCnt = 0;
PRInt32 cnt = 0;
PRInt32 sleepCnt = 1;
while (!pListen->m_done && (abortCnt < kHungAbortCount)) {
PR_Sleep( sleepCnt);
cnt++;
if (cnt > kHungCount) {
abortCnt++;
sleepCnt *= 2;
cnt = 0;
}
}
if (abortCnt >= kHungAbortCount) {
IMPORT_LOG0( "**** Create and send message hung\n");
IMPORT_LOG1( "Headers: %s\n", m_pHeaders);
IMPORT_LOG1( "Body: %s\n", m_pBody);
rv = NS_ERROR_FAILURE;
}
IMPORT_LOG0( " done with CreateAndSendMessage\n");
}
if (pMimeType)
nsCRT::free( pMimeType);
if (pListen->m_location) {
pMsg->FromFileSpec( pListen->m_location);
rv = NS_OK;
IMPORT_LOG0( "Eudora compose successful\n");
}
else {
rv = NS_ERROR_FAILURE;
IMPORT_LOG0( "*** Error, Eudora compose unsuccessful\n");
}
pListen->Reset();
return( rv);
}

View File

@ -0,0 +1,71 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsEudoraCompose_h__
#define nsEudoraCompose_h__
#include "nsString.h"
#include "nsIFileSpec.h"
#include "nsVoidArray.h"
class nsIMsgSend;
class nsIMsgCompFields;
class nsIMsgIdentity;
class nsIMsgSendListener;
class nsIIOService;
#include "nsIMsgSend.h"
class nsEudoraCompose {
public:
nsEudoraCompose();
~nsEudoraCompose();
nsresult SendMessage( nsIFileSpec *pMsg);
void SetBody( const char *pBody, PRInt32 len) { m_pBody = pBody; m_bodyLen = len;}
void SetHeaders( const char *pHeaders, PRInt32 len) { m_pHeaders = pHeaders; m_headerLen = len;}
void SetAttachments( nsVoidArray *pAttachments) { m_pAttachments = pAttachments;}
private:
nsresult CreateComponents( void);
nsresult CreateIdentity( void);
void GetHeaderValue( const char *pHeader, nsString& val);
void ExtractCharset( nsString& str);
void ExtractType( nsString& str);
nsMsgAttachedFile * GetLocalAttachments( void);
void CleanUpAttach( nsMsgAttachedFile *a, PRInt32 count);
private:
nsVoidArray * m_pAttachments;
nsIMsgSendListener * m_pListener;
nsIMsgSend * m_pMsgSend;
nsIMsgCompFields * m_pMsgFields;
nsIMsgIdentity * m_pIdentity;
nsIIOService * m_pIOService;
PRInt32 m_headerLen;
const char * m_pHeaders;
PRInt32 m_bodyLen;
const char * m_pBody;
};
#endif /* nsEudoraCompose_h__ */

View File

@ -0,0 +1,352 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
Eudora import module
*/
#include "nsCOMPtr.h"
#include "nsIModule.h"
#include "nsIGenericFactory.h"
#include "nsIServiceManager.h"
#include "nsIRegistry.h"
#include "nsIImportService.h"
#include "nsEudoraImport.h"
#include "EudoraDebugLog.h"
static NS_DEFINE_CID(kEudoraImportCID, NS_EUDORAIMPORT_CID);
static NS_DEFINE_CID(kImportServiceCID, NS_IMPORTSERVICE_CID);
static NS_DEFINE_CID(kRegistryCID, NS_REGISTRY_CID);
// Module implementation for the Eudora import library
class nsEudoraImportModule : public nsIModule
{
public:
nsEudoraImportModule();
virtual ~nsEudoraImportModule();
NS_DECL_ISUPPORTS
NS_DECL_NSIMODULE
protected:
nsresult Initialize();
void Shutdown();
PRBool mInitialized;
nsCOMPtr<nsIGenericFactory> mFactory;
};
//----------------------------------------------------------------------
// Functions used to create new instances of a given object by the
// generic factory.
#define MAKE_CTOR(_iface, _name) \
static NS_IMETHODIMP \
CreateNew##_name(nsISupports* aOuter, REFNSIID aIID, void **aResult) \
{ \
if (!aResult) { \
return NS_ERROR_INVALID_POINTER; \
} \
if (aOuter) { \
*aResult = nsnull; \
return NS_ERROR_NO_AGGREGATION; \
} \
nsI##_iface* inst; \
nsresult rv = NS_New##_name(&inst); \
if (NS_FAILED(rv)) { \
*aResult = nsnull; \
return rv; \
} \
rv = inst->QueryInterface(aIID, aResult); \
if (NS_FAILED(rv)) { \
*aResult = nsnull; \
} \
NS_RELEASE(inst); /* get rid of extra refcnt */ \
return rv; \
}
MAKE_CTOR(ImportModule, EudoraImport)
//----------------------------------------------------------------------
static NS_DEFINE_IID(kIModuleIID, NS_IMODULE_IID);
nsEudoraImportModule::nsEudoraImportModule()
: mInitialized(PR_FALSE)
{
NS_INIT_ISUPPORTS();
}
nsEudoraImportModule::~nsEudoraImportModule()
{
Shutdown();
}
NS_IMPL_ISUPPORTS(nsEudoraImportModule, kIModuleIID)
// Perform our one-time intialization for this module
nsresult
nsEudoraImportModule::Initialize()
{
if (mInitialized) {
return NS_OK;
}
mInitialized = PR_TRUE;
return NS_OK;
}
// Shutdown this module, releasing all of the module resources
void
nsEudoraImportModule::Shutdown()
{
// Release the factory object
mFactory = nsnull;
}
// Create a factory object for creating instances of aClass.
NS_IMETHODIMP
nsEudoraImportModule::GetClassObject(nsIComponentManager *aCompMgr,
const nsCID& aClass,
const nsIID& aIID,
void** r_classObj)
{
nsresult rv;
// Defensive programming: Initialize *r_classObj in case of error below
if (!r_classObj) {
return NS_ERROR_INVALID_POINTER;
}
*r_classObj = NULL;
// Do one-time-only initialization if necessary
if (!mInitialized) {
rv = Initialize();
if (NS_FAILED(rv)) {
// Initialization failed! yikes!
return rv;
}
}
// Choose the appropriate factory, based on the desired instance
// class type (aClass).
nsCOMPtr<nsIGenericFactory> fact;
if (aClass.Equals(kEudoraImportCID)) {
if (!mFactory) {
// Create and save away the factory object for creating
// new instances of Sample. This way if we are called
// again for the factory, we won't need to create a new
// one.
rv = NS_NewGenericFactory(getter_AddRefs(mFactory),
CreateNewEudoraImport);
}
fact = mFactory;
}
else {
rv = NS_ERROR_FACTORY_NOT_REGISTERED;
#ifdef DEBUG
char* cs = aClass.ToString();
printf("+++ nsEudoraImportModule: unable to create factory for %s\n", cs);
nsCRT::free(cs);
#endif
}
if (fact) {
rv = fact->QueryInterface(aIID, r_classObj);
}
return rv;
}
//----------------------------------------
struct Components {
const char* mDescription;
const nsID* mCID;
const char* mProgID;
};
// The list of components we register
static Components gComponents[] = {
{ "Eudora Import Component", &kEudoraImportCID,
"component://mozilla/import/import-eudora", },
};
#define NUM_COMPONENTS (sizeof(gComponents) / sizeof(gComponents[0]))
nsresult GetImportModulesRegKey( nsIRegistry *reg, nsRegistryKey *pKey)
{
nsRegistryKey nScapeKey;
nsresult rv = reg->GetSubtree( nsIRegistry::Common, "Netscape", &nScapeKey);
if (NS_FAILED(rv)) {
rv = reg->AddSubtree( nsIRegistry::Common, "Netscape", &nScapeKey);
}
if (NS_FAILED( rv))
return( rv);
nsRegistryKey iKey;
rv = reg->GetSubtree( nScapeKey, "Import", &iKey);
if (NS_FAILED( rv)) {
rv = reg->AddSubtree( nScapeKey, "Import", &iKey);
}
if (NS_FAILED( rv))
return( rv);
rv = reg->GetSubtree( iKey, "Modules", pKey);
if (NS_FAILED( rv)) {
rv = reg->AddSubtree( iKey, "Modules", pKey);
}
return( rv);
}
NS_IMETHODIMP
nsEudoraImportModule::RegisterSelf(nsIComponentManager *aCompMgr,
nsIFileSpec* aPath,
const char* registryLocation,
const char* componentType)
{
nsresult rv = NS_OK;
#ifdef DEBUG
printf("*** Registering Eudora import components\n");
#endif
Components* cp = gComponents;
Components* end = cp + NUM_COMPONENTS;
while (cp < end) {
rv = aCompMgr->RegisterComponentSpec(*cp->mCID, cp->mDescription,
cp->mProgID, aPath, PR_TRUE,
PR_TRUE);
if (NS_FAILED(rv)) {
#ifdef DEBUG
printf("nsEudoraImportModule: unable to register %s component => %x\n",
cp->mDescription, rv);
#endif
break;
}
cp++;
}
{
NS_WITH_SERVICE( nsIRegistry, reg, kRegistryCID, &rv);
if (NS_FAILED(rv)) {
IMPORT_LOG0( "*** Import Eudora, ERROR GETTING THE Registry\n");
return rv;
}
rv = reg->OpenDefault();
if (NS_FAILED(rv)) {
IMPORT_LOG0( "*** Import Eudora, ERROR OPENING THE REGISTRY\n");
return( rv);
}
nsRegistryKey importKey;
rv = GetImportModulesRegKey( reg, &importKey);
if (NS_FAILED( rv)) {
IMPORT_LOG0( "*** Import Eudora, ERROR getting Netscape/Import registry key\n");
return( rv);
}
nsRegistryKey key;
rv = reg->AddSubtree( importKey, "Eudora", &key);
if (NS_FAILED(rv)) return( rv);
rv = reg->SetString( key, "Supports", kEudoraSupportsString);
if (NS_FAILED(rv)) return( rv);
char *myCID = kEudoraImportCID.ToString();
rv = reg->SetString( key, "CLSID", myCID);
delete [] myCID;
if (NS_FAILED(rv)) return( rv);
}
return rv;
}
NS_IMETHODIMP
nsEudoraImportModule::UnregisterSelf(nsIComponentManager* aCompMgr,
nsIFileSpec* aPath,
const char* registryLocation)
{
#ifdef DEBUG
printf("*** Unregistering Eudora import components\n");
#endif
Components* cp = gComponents;
Components* end = cp + NUM_COMPONENTS;
while (cp < end) {
nsresult rv = aCompMgr->UnregisterComponentSpec(*cp->mCID, aPath);
if (NS_FAILED(rv)) {
#ifdef DEBUG
printf("nsEudoraImportModule: unable to unregister %s component => %x\n",
cp->mDescription, rv);
#endif
}
cp++;
}
return NS_OK;
}
NS_IMETHODIMP
nsEudoraImportModule::CanUnload(nsIComponentManager *aCompMgr, PRBool *okToUnload)
{
if (!okToUnload) {
return NS_ERROR_INVALID_POINTER;
}
*okToUnload = PR_FALSE;
return NS_ERROR_FAILURE;
}
//----------------------------------------------------------------------
static nsEudoraImportModule *gModule = NULL;
extern "C" NS_EXPORT nsresult NSGetModule(nsIComponentManager *servMgr,
nsIFileSpec* location,
nsIModule** return_cobj)
{
nsresult rv = NS_OK;
NS_ASSERTION(return_cobj, "Null argument");
NS_ASSERTION(gModule == NULL, "nsEudoraImportModule: Module already created.");
// Create an initialize the layout module instance
nsEudoraImportModule *m = new nsEudoraImportModule();
if (!m) {
return NS_ERROR_OUT_OF_MEMORY;
}
// Increase refcnt and store away nsIModule interface to m in return_cobj
rv = m->QueryInterface(nsIModule::GetIID(), (void**)return_cobj);
if (NS_FAILED(rv)) {
delete m;
m = nsnull;
}
gModule = m; // WARNING: Weak Reference
return rv;
}

View File

@ -0,0 +1,568 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
Eudora import mail and addressbook interfaces
*/
#include "nscore.h"
#include "nsCRT.h"
#include "nsString.h"
#include "nsIServiceManager.h"
#include "nsIImportService.h"
#include "nsComponentManagerUtils.h"
#include "nsEudoraImport.h"
#include "nsIAllocator.h"
#include "nsIImportService.h"
#include "nsIImportMail.h"
#include "nsIImportMailboxDescriptor.h"
#include "nsIImportGeneric.h"
#include "nsIImportAddressBooks.h"
#include "nsIImportABDescriptor.h"
#include "nsIImportSettings.h"
#include "nsIOutputStream.h"
#include "nsIAddrDatabase.h"
#include "nsTextFormater.h"
#include "nsEudoraStringBundle.h"
#include "nsEudoraSettings.h"
#ifdef XP_PC
#include "nsEudoraWin32.h"
#endif
#ifdef XP_MAC
#include "nsEudoraMac.h"
#endif
#include "EudoraDebugLog.h"
static NS_DEFINE_CID(kImportServiceCID, NS_IMPORTSERVICE_CID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
class ImportMailImpl : public nsIImportMail
{
public:
ImportMailImpl();
virtual ~ImportMailImpl();
static nsresult Create(nsIImportMail** aImport);
// nsISupports interface
NS_DECL_ISUPPORTS
// nsIImportmail interface
/* void GetDefaultLocation (out nsIFileSpec location, out boolean found, out boolean userVerify); */
NS_IMETHOD GetDefaultLocation(nsIFileSpec **location, PRBool *found, PRBool *userVerify);
/* nsISupportsArray FindMailboxes (in nsIFileSpec location); */
NS_IMETHOD FindMailboxes(nsIFileSpec *location, nsISupportsArray **_retval);
/* void ImportMailbox (in nsIImportMailboxDescriptor source, in nsIFileSpec destination, out boolean fatalError); */
NS_IMETHOD ImportMailbox(nsIImportMailboxDescriptor *source, nsIFileSpec *destination,
PRUnichar **pErrorLog, PRUnichar **pSuccessLog, PRBool *fatalError);
/* unsigned long GetImportProgress (); */
NS_IMETHOD GetImportProgress(PRUint32 *_retval);
private:
static void ReportSuccess( nsString& name, PRInt32 count, nsString *pStream);
static void ReportError( PRInt32 errorNum, nsString& name, nsString *pStream);
static void AddLinebreak( nsString *pStream);
static void SetLogs( nsString& success, nsString& error, PRUnichar **pError, PRUnichar **pSuccess);
private:
#ifdef XP_PC
nsEudoraWin32 m_eudora;
#endif
#ifdef XP_MAC
nsEudoraMac m_eudora;
#endif
};
class ImportAddressImpl : public nsIImportAddressBooks
{
public:
ImportAddressImpl();
virtual ~ImportAddressImpl();
static nsresult Create(nsIImportAddressBooks** aImport);
// nsISupports interface
NS_DECL_ISUPPORTS
// nsIImportAddressBooks interface
/* PRBool GetSupportsMultiple (); */
NS_IMETHOD GetSupportsMultiple(PRBool *_retval) { *_retval = PR_FALSE; return( NS_OK);}
/* PRBool GetAutoFind (out wstring description); */
NS_IMETHOD GetAutoFind(PRUnichar **description, PRBool *_retval);
/* PRBool GetNeedsFieldMap (); */
NS_IMETHOD GetNeedsFieldMap(PRBool *_retval) { *_retval = PR_FALSE; return( NS_OK);}
/* void GetDefaultLocation (out nsIFileSpec location, out boolean found, out boolean userVerify); */
NS_IMETHOD GetDefaultLocation(nsIFileSpec **location, PRBool *found, PRBool *userVerify)
{ return( NS_ERROR_FAILURE);}
/* nsISupportsArray FindAddressBooks (in nsIFileSpec location); */
NS_IMETHOD FindAddressBooks(nsIFileSpec *location, nsISupportsArray **_retval);
/* nsISupports GetFieldMap (in nsIImportABDescriptor source); */
NS_IMETHOD GetFieldMap(nsIImportABDescriptor *source, nsISupports **_retval)
{ return( NS_ERROR_FAILURE); }
/* void ImportAddressBook (in nsIImportABDescriptor source, in nsISupports destination, in nsISupports fieldMap, out boolean fatalError); */
NS_IMETHOD ImportAddressBook( nsIImportABDescriptor *source,
nsIAddrDatabase * destination,
nsISupports * fieldMap,
PRUnichar ** errorLog,
PRUnichar ** successLog,
PRBool * fatalError);
/* unsigned long GetImportProgress (); */
NS_IMETHOD GetImportProgress(PRUint32 *_retval);
private:
};
////////////////////////////////////////////////////////////////////////
nsresult NS_NewEudoraImport(nsIImportModule** aImport)
{
NS_PRECONDITION(aImport != nsnull, "null ptr");
if (! aImport)
return NS_ERROR_NULL_POINTER;
*aImport = new nsEudoraImport();
if (! *aImport)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aImport);
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
nsEudoraImport::nsEudoraImport()
{
NS_INIT_REFCNT();
IMPORT_LOG0( "nsEudoraImport Module Created\n");
}
nsEudoraImport::~nsEudoraImport()
{
IMPORT_LOG0( "nsEudoraImport Module Deleted\n");
}
NS_IMPL_ISUPPORTS(nsEudoraImport, nsIImportModule::GetIID());
NS_IMETHODIMP nsEudoraImport::GetName( PRUnichar **name)
{
NS_PRECONDITION(name != nsnull, "null ptr");
if (! name)
return NS_ERROR_NULL_POINTER;
// nsString title = "Outlook Express";
// *name = title.ToNewUnicode();
*name = nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_NAME);
return NS_OK;
}
NS_IMETHODIMP nsEudoraImport::GetDescription( PRUnichar **name)
{
NS_PRECONDITION(name != nsnull, "null ptr");
if (! name)
return NS_ERROR_NULL_POINTER;
// nsString desc = "Outlook Express mail and address books";
// *name = desc.ToNewUnicode();
*name = nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_DESCRIPTION);
return NS_OK;
}
NS_IMETHODIMP nsEudoraImport::GetSupports( char **supports)
{
NS_PRECONDITION(supports != nsnull, "null ptr");
if (! supports)
return NS_ERROR_NULL_POINTER;
*supports = nsCRT::strdup( kEudoraSupportsString);
return( NS_OK);
}
NS_IMETHODIMP nsEudoraImport::GetImportInterface( const char *pImportType, nsISupports **ppInterface)
{
NS_PRECONDITION(pImportType != nsnull, "null ptr");
if (! pImportType)
return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(ppInterface != nsnull, "null ptr");
if (! ppInterface)
return NS_ERROR_NULL_POINTER;
*ppInterface = nsnull;
nsresult rv;
if (!nsCRT::strcmp( pImportType, "mail")) {
// create the nsIImportMail interface and return it!
nsIImportMail * pMail = nsnull;
nsIImportGeneric *pGeneric = nsnull;
rv = ImportMailImpl::Create( &pMail);
if (NS_SUCCEEDED( rv)) {
NS_WITH_SERVICE( nsIImportService, impSvc, kImportServiceCID, &rv);
if (NS_SUCCEEDED( rv)) {
rv = impSvc->CreateNewGenericMail( &pGeneric);
if (NS_SUCCEEDED( rv)) {
pGeneric->SetData( "mailInterface", pMail);
nsString name;
nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_NAME, name);
pGeneric->SetData( "name", (nsISupports *) name.GetUnicode());
rv = pGeneric->QueryInterface( kISupportsIID, (void **)ppInterface);
}
}
}
NS_IF_RELEASE( pMail);
NS_IF_RELEASE( pGeneric);
return( rv);
}
if (!nsCRT::strcmp( pImportType, "addressbook")) {
// create the nsIImportMail interface and return it!
nsIImportAddressBooks * pAddress = nsnull;
nsIImportGeneric * pGeneric = nsnull;
rv = ImportAddressImpl::Create( &pAddress);
if (NS_SUCCEEDED( rv)) {
NS_WITH_SERVICE( nsIImportService, impSvc, kImportServiceCID, &rv);
if (NS_SUCCEEDED( rv)) {
rv = impSvc->CreateNewGenericAddressBooks( &pGeneric);
if (NS_SUCCEEDED( rv)) {
pGeneric->SetData( "addressInterface", pAddress);
rv = pGeneric->QueryInterface( kISupportsIID, (void **)ppInterface);
}
}
}
NS_IF_RELEASE( pAddress);
NS_IF_RELEASE( pGeneric);
return( rv);
}
if (!nsCRT::strcmp( pImportType, "settings")) {
nsIImportSettings *pSettings = nsnull;
rv = nsEudoraSettings::Create( &pSettings);
if (NS_SUCCEEDED( rv)) {
pSettings->QueryInterface( kISupportsIID, (void **)ppInterface);
}
NS_IF_RELEASE( pSettings);
return( rv);
}
return( NS_ERROR_NOT_AVAILABLE);
}
/////////////////////////////////////////////////////////////////////////////////
nsresult ImportMailImpl::Create(nsIImportMail** aImport)
{
NS_PRECONDITION(aImport != nsnull, "null ptr");
if (! aImport)
return NS_ERROR_NULL_POINTER;
*aImport = new ImportMailImpl();
if (! *aImport)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aImport);
return NS_OK;
}
ImportMailImpl::ImportMailImpl()
{
NS_INIT_REFCNT();
}
ImportMailImpl::~ImportMailImpl()
{
}
NS_IMPL_ISUPPORTS(ImportMailImpl, nsIImportMail::GetIID());
NS_IMETHODIMP ImportMailImpl::GetDefaultLocation( nsIFileSpec **ppLoc, PRBool *found, PRBool *userVerify)
{
NS_PRECONDITION(ppLoc != nsnull, "null ptr");
NS_PRECONDITION(found != nsnull, "null ptr");
NS_PRECONDITION(userVerify != nsnull, "null ptr");
if (!ppLoc || !found || !userVerify)
return NS_ERROR_NULL_POINTER;
nsresult rv;
nsIFileSpec * spec;
if (NS_FAILED( rv = NS_NewFileSpec( &spec)))
return( rv);
*found = m_eudora.FindMailFolder( spec);
// FIXME: Implement this, we need to look in the registry on windows
// and in the system folder on Mac.
*found = PR_TRUE;
*ppLoc = spec;
*userVerify = PR_TRUE;
return( NS_OK);
}
NS_IMETHODIMP ImportMailImpl::FindMailboxes( nsIFileSpec *pLoc, nsISupportsArray **ppArray)
{
NS_PRECONDITION(pLoc != nsnull, "null ptr");
NS_PRECONDITION(ppArray != nsnull, "null ptr");
if (!pLoc || !ppArray)
return NS_ERROR_NULL_POINTER;
m_eudora.FindMailboxes( pLoc, ppArray);
return( NS_OK);
}
void ImportMailImpl::AddLinebreak( nsString *pStream)
{
if (pStream)
pStream->Append( NS_LINEBREAK);
}
void ImportMailImpl::ReportSuccess( nsString& name, PRInt32 count, nsString *pStream)
{
if (!pStream)
return;
// load the success string
PRUnichar *pFmt = nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_MAILBOX_SUCCESS);
PRUnichar *pText = nsTextFormater::smprintf( pFmt, name.GetUnicode(), count);
pStream->Append( pText);
nsTextFormater::smprintf_free( pText);
nsEudoraStringBundle::FreeString( pFmt);
AddLinebreak( pStream);
}
void ImportMailImpl::ReportError( PRInt32 errorNum, nsString& name, nsString *pStream)
{
if (!pStream)
return;
// load the error string
PRUnichar *pFmt = nsEudoraStringBundle::GetStringByID( errorNum);
PRUnichar *pText = nsTextFormater::smprintf( pFmt, name.GetUnicode());
pStream->Append( pText);
IMPORT_LOG1( "%S\n", pText);
nsTextFormater::smprintf_free( pText);
nsEudoraStringBundle::FreeString( pFmt);
AddLinebreak( pStream);
}
void ImportMailImpl::SetLogs( nsString& success, nsString& error, PRUnichar **pError, PRUnichar **pSuccess)
{
if (pError)
*pError = error.ToNewUnicode();
if (pSuccess)
*pSuccess = success.ToNewUnicode();
}
NS_IMETHODIMP ImportMailImpl::ImportMailbox( nsIImportMailboxDescriptor *pSource,
nsIFileSpec *pDestination,
PRUnichar **pErrorLog,
PRUnichar **pSuccessLog,
PRBool *fatalError)
{
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) {
IMPORT_LOG0( "*** Bad param passed to eudora mailbox import\n");
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;
PRUnichar * pName;
if (NS_SUCCEEDED( pSource->GetDisplayName( &pName))) {
name = pName;
nsCRT::free( pName);
}
PRUint32 mailSize = 0;
pSource->GetSize( &mailSize);
if (mailSize == 0) {
IMPORT_LOG0( "Mailbox size is 0, skipping mailbox.\n");
ReportSuccess( name, 0, &success);
SetLogs( success, error, pErrorLog, pSuccessLog);
return( NS_OK);
}
nsIFileSpec * inFile;
if (NS_FAILED( pSource->GetFileSpec( &inFile))) {
ReportError( EUDORAIMPORT_MAILBOX_BADSOURCEFILE, name, &error);
SetLogs( success, error, pErrorLog, pSuccessLog);
return( NS_ERROR_FAILURE);
}
#ifdef IMPORT_DEBUG
char *pPath;
inFile->GetNativePath( &pPath);
IMPORT_LOG1( "Import mailbox: %s\n", pPath);
nsCRT::free( pPath);
#endif
PRInt32 msgCount = 0;
nsresult rv = NS_OK;
rv = m_eudora.ImportMailbox( &abort, name.GetUnicode(), inFile, pDestination, &msgCount);
inFile->Release();
if (NS_SUCCEEDED( rv)) {
ReportSuccess( name, msgCount, &success);
}
else {
ReportError( EUDORAIMPORT_MAILBOX_CONVERTERROR, name, &error);
}
SetLogs( success, error, pErrorLog, pSuccessLog);
IMPORT_LOG0( "*** Returning from eudora mailbox import\n");
return( rv);
}
NS_IMETHODIMP ImportMailImpl::GetImportProgress( PRUint32 *pDoneSoFar)
{
NS_PRECONDITION(pDoneSoFar != nsnull, "null ptr");
if (! pDoneSoFar)
return NS_ERROR_NULL_POINTER;
// TLR: FIXME: Figure our how to update this from the import
// of the current mailbox.
*pDoneSoFar = 0;
return( NS_OK);
}
nsresult ImportAddressImpl::Create(nsIImportAddressBooks** aImport)
{
NS_PRECONDITION(aImport != nsnull, "null ptr");
if (! aImport)
return NS_ERROR_NULL_POINTER;
*aImport = new ImportAddressImpl();
if (! *aImport)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aImport);
return NS_OK;
}
ImportAddressImpl::ImportAddressImpl()
{
NS_INIT_REFCNT();
}
ImportAddressImpl::~ImportAddressImpl()
{
}
NS_IMPL_ISUPPORTS(ImportAddressImpl, nsIImportAddressBooks::GetIID());
NS_IMETHODIMP ImportAddressImpl::GetAutoFind(PRUnichar **description, PRBool *_retval)
{
NS_PRECONDITION(description != nsnull, "null ptr");
NS_PRECONDITION(_retval != nsnull, "null ptr");
if (! description || !_retval)
return NS_ERROR_NULL_POINTER;
*_retval = PR_FALSE;
nsString str = "Eudora address book";
*description = str.ToNewUnicode();
return( NS_OK);
}
NS_IMETHODIMP ImportAddressImpl::FindAddressBooks(nsIFileSpec *location, nsISupportsArray **_retval)
{
NS_PRECONDITION(_retval != nsnull, "null ptr");
if (!_retval)
return NS_ERROR_NULL_POINTER;
// FIXME: Find the Eudora address books
return( NS_ERROR_FAILURE);
}
NS_IMETHODIMP ImportAddressImpl::ImportAddressBook( nsIImportABDescriptor *source,
nsIAddrDatabase * destination,
nsISupports * fieldMap,
PRUnichar ** errorLog,
PRUnichar ** successLog,
PRBool * fatalError)
{
return( NS_ERROR_FAILURE);
}
NS_IMETHODIMP ImportAddressImpl::GetImportProgress(PRUint32 *_retval)
{
return( NS_OK);
}

View File

@ -0,0 +1,68 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsEudoraImport_h___
#define nsEudoraImport_h___
#include "nsIImportModule.h"
#include "nsCOMPtr.h"
#define NS_EUDORAIMPORT_CID \
{ /* c8448da0-8f83-11d3-a206-00a0cc26da63 */ \
0xc8448da0, 0x8f83, 0x11d3, \
{0xa2, 0x6, 0x0, 0xa0, 0xcc, 0x26, 0xda, 0x63 }}
#define kEudoraSupportsString NS_IMPORT_MAIL_STR "," NS_IMPORT_ADDRESS_STR "," NS_IMPORT_SETTINGS_STR
class nsEudoraImport : public nsIImportModule
{
public:
nsEudoraImport();
virtual ~nsEudoraImport();
NS_DECL_ISUPPORTS
////////////////////////////////////////////////////////////////////////////////////////
// we suppport the nsIImportModule interface
////////////////////////////////////////////////////////////////////////////////////////
/* readonly attribute wstring name; */
NS_IMETHOD GetName(PRUnichar * *aName);
/* readonly attribute wstring description; */
NS_IMETHOD GetDescription(PRUnichar * *aDescription);
/* readonly attribute string supports; */
NS_IMETHOD GetSupports(char * *aSupports);
/* nsISupports GetImportInterface (in string importType); */
NS_IMETHOD GetImportInterface(const char *importType, nsISupports **_retval);
protected:
};
extern nsresult NS_NewEudoraImport(nsIImportModule** aImport);
#endif /* nsEudoraImport_h___ */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,145 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsEudoraMailbox_h__
#define nsEudoraMailbox_h__
#include "nscore.h"
#include "nsString.h"
#include "nsVoidArray.h"
#include "nsIFileSpec.h"
#include "nsISupportsArray.h"
typedef struct {
nsIFileSpec * pAttachment;
char * mimeType;
char * description;
} EudoraAttachment;
typedef struct {
PRUint32 offset;
PRUint32 size;
nsIFileSpec * pFile;
} ReadFileState;
class SimpleBuffer {
public:
SimpleBuffer() {m_pBuffer = nsnull; m_size = 0; m_growBy = 4096; m_writeOffset = 0;
m_bytesInBuf = 0;}
~SimpleBuffer() { if (m_pBuffer) delete [] m_pBuffer;}
PRBool Allocate( PRInt32 sz) {
if (m_pBuffer) delete [] m_pBuffer;
m_pBuffer = new char[sz];
if (m_pBuffer) { m_size = sz; return( PR_TRUE); }
else { m_size = 0; return( PR_FALSE);}
}
PRBool Grow( PRInt32 newSize) { if (newSize > m_size) return( ReAllocate( newSize)); else return( PR_TRUE);}
PRBool ReAllocate( PRInt32 newSize) {
if (newSize <= m_size) return( PR_TRUE);
char *pOldBuffer = m_pBuffer;
PRInt32 oldSize = m_size;
m_pBuffer = nsnull;
while (m_size < newSize) m_size += m_growBy;
if (Allocate( m_size)) {
if (pOldBuffer) { nsCRT::memcpy( m_pBuffer, pOldBuffer, oldSize); delete [] pOldBuffer;}
return( PR_TRUE);
}
else { m_pBuffer = pOldBuffer; m_size = oldSize; return( PR_FALSE);}
}
PRBool Write( PRInt32 offset, const char *pData, PRInt32 len) {
if (!len) return( PR_TRUE);
if (!Grow( offset + len)) return( PR_FALSE);
nsCRT::memcpy( m_pBuffer + offset, pData, len);
return( PR_TRUE);
}
PRBool Write( const char *pData, PRInt32 len) {
if (Write( m_writeOffset, pData, len)) { m_writeOffset += len; return( PR_TRUE);}
else return( PR_FALSE);
}
char * m_pBuffer;
PRInt32 m_bytesInBuf; // used when reading into this buffer
PRInt32 m_size; // allocated size of buffer
PRInt32 m_growBy; // duh
PRInt32 m_writeOffset; // used when writing into and reading from the buffer
};
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
class nsEudoraMailbox {
public:
nsEudoraMailbox();
virtual ~nsEudoraMailbox();
// Things that must be overridden because they are platform specific.
// retrieve the mail folder
virtual PRBool FindMailFolder( nsIFileSpec *pFolder) { return( PR_FALSE);}
// get the list of mailboxes
virtual nsresult FindMailboxes( nsIFileSpec *pRoot, nsISupportsArray **ppArray) { return( NS_ERROR_FAILURE);}
// get the toc file corresponding to this mailbox
virtual nsresult FindTOCFile( nsIFileSpec *pMailFile, nsIFileSpec **pTOCFile, PRBool *pDeleteToc) { return( NS_ERROR_FAILURE);}
// interpret the attachment line and return the attached file
virtual nsresult GetAttachmentInfo( const char *pFileName, nsIFileSpec *pSpec, nsCString& mimeType) { return( NS_ERROR_FAILURE);}
// Non-platform specific common stuff
// import a mailbox
nsresult ImportMailbox( PRBool *pAbort, const PRUnichar *pName, nsIFileSpec *pSrc, nsIFileSpec *pDst, PRInt32 *pMsgCount);
static PRInt32 IsEudoraFromSeparator( const char *pData, PRInt32 maxLen);
protected:
nsresult CreateTempFile( nsIFileSpec **ppSpec);
nsresult DeleteFile( nsIFileSpec *pSpec);
private:
nsresult CompactMailbox( PRBool *pAbort, nsIFileSpec *pMail, nsIFileSpec *pToc, nsIFileSpec *pDst);
nsresult ReadNextMessage( ReadFileState *pState, SimpleBuffer& copy, SimpleBuffer& header, SimpleBuffer& body);
nsresult FillMailBuffer( ReadFileState *pState, SimpleBuffer& read);
PRInt32 FindStartLine( SimpleBuffer& data);
PRInt32 FindNextEndLine( SimpleBuffer& data);
PRInt32 IsEndHeaders( SimpleBuffer& data);
nsresult CopyComposedMessage( nsIFileSpec *pSrc, nsIFileSpec *pDst, SimpleBuffer& copy);
nsresult WriteFromSep( nsIFileSpec *pDst);
void EmptyAttachments( void);
nsresult ExamineAttachment( SimpleBuffer& data);
PRBool AddAttachment( nsCString& fileName);
static PRInt32 AsciiToLong( const char *pChar, PRInt32 len);
static int IsWeekDayStr( const char *pStr);
static int IsMonthStr( const char *pStr);
private:
PRUint32 m_mailSize;
PRInt32 m_fromLen;
nsVoidArray m_attachments;
};
#endif /* nsEudoraMailbox_h__ */

View File

@ -0,0 +1,138 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
Eudora settings
*/
#include "nsCOMPtr.h"
#include "nscore.h"
#include "nsEudoraSettings.h"
#include "nsEudoraStringBundle.h"
#include "EudoraDebugLog.h"
#ifdef XP_PC
#include "nsEudoraWin32.h"
#endif
////////////////////////////////////////////////////////////////////////
nsresult nsEudoraSettings::Create(nsIImportSettings** aImport)
{
NS_PRECONDITION(aImport != nsnull, "null ptr");
if (! aImport)
return NS_ERROR_NULL_POINTER;
*aImport = new nsEudoraSettings();
if (! *aImport)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aImport);
return NS_OK;
}
nsEudoraSettings::nsEudoraSettings()
{
NS_INIT_REFCNT();
m_pLocation = nsnull;
}
nsEudoraSettings::~nsEudoraSettings()
{
NS_IF_RELEASE( m_pLocation);
}
NS_IMPL_ISUPPORTS(nsEudoraSettings, nsIImportSettings::GetIID());
NS_IMETHODIMP nsEudoraSettings::AutoLocate(PRUnichar **description, nsIFileSpec **location, PRBool *_retval)
{
NS_PRECONDITION(description != nsnull, "null ptr");
NS_PRECONDITION(_retval != nsnull, "null ptr");
NS_PRECONDITION(location != nsnull, "null ptr");
if (!description || !_retval || !location)
return( NS_ERROR_NULL_POINTER);
*description = nsnull;
*_retval = PR_FALSE;
*location = nsnull;
nsresult rv;
if (NS_FAILED( rv = NS_NewFileSpec( location)))
return( rv);
*description = nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_NAME);
#ifdef XP_PC
*_retval = nsEudoraWin32::FindSettingsFile( *location);
#endif
m_pLocation = *location;
NS_IF_ADDREF( m_pLocation);
return( NS_OK);
}
NS_IMETHODIMP nsEudoraSettings::SetLocation(nsIFileSpec *location)
{
NS_IF_RELEASE( m_pLocation);
m_pLocation = location;
NS_IF_ADDREF( m_pLocation);
return( NS_OK);
}
NS_IMETHODIMP nsEudoraSettings::Import(nsIMsgAccount **localMailAccount, PRBool *_retval)
{
NS_PRECONDITION( _retval != nsnull, "null ptr");
nsresult rv;
*_retval = PR_FALSE;
// Get the settings file if it doesn't exist
if (!m_pLocation) {
#ifdef XP_PC
if (NS_SUCCEEDED( rv = NS_NewFileSpec( &m_pLocation))) {
if (!nsEudoraWin32::FindSettingsFile( m_pLocation)) {
NS_IF_RELEASE( m_pLocation);
m_pLocation = nsnull;
}
}
#endif
}
if (!m_pLocation) {
IMPORT_LOG0( "*** Error, unable to locate settings file for import.\n");
return( NS_ERROR_FAILURE);
}
// do the settings import
#ifdef XP_PC
*_retval = nsEudoraWin32::ImportSettings( m_pLocation, localMailAccount);
#endif
if (*_retval) {
IMPORT_LOG0( "Successful import of eudora settings\n");
}
else {
IMPORT_LOG0( "*** Error, Unsuccessful import of eudora settings\n");
}
return( NS_OK);
}

View File

@ -0,0 +1,42 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsEudoraSettings_h___
#define nsEudoraSettings_h___
#include "nsIImportSettings.h"
#include "nsIFileSpec.h"
class nsEudoraSettings : public nsIImportSettings {
public:
nsEudoraSettings();
virtual ~nsEudoraSettings();
static nsresult Create(nsIImportSettings** aImport);
// nsISupports interface
NS_DECL_ISUPPORTS
// nsIImportSettings interface
NS_DECL_NSIIMPORTSETTINGS
private:
nsIFileSpec * m_pLocation;
};
#endif /* nsEudoraSettings_h___ */

View File

@ -0,0 +1,82 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "prprf.h"
#include "prmem.h"
#include "nsCOMPtr.h"
#include "nsIStringBundle.h"
#include "nsEudoraStringBundle.h"
#include "nsIServiceManager.h"
#include "nsIURI.h"
/* This is the next generation string retrieval call */
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
#define EUDORA_MSGS_URL "chrome://messenger/locale/eudoraImportMsgs.properties"
nsIStringBundle *nsEudoraStringBundle::GetStringBundle( void)
{
nsresult rv;
char* propertyURL = EUDORA_MSGS_URL;
nsIStringBundle* sBundle = nsnull;
NS_WITH_SERVICE(nsIStringBundleService, sBundleService, kStringBundleServiceCID, &rv);
if (NS_SUCCEEDED(rv) && (nsnull != sBundleService)) {
nsILocale * locale = nsnull;
rv = sBundleService->CreateBundle(propertyURL, locale, &sBundle);
}
return( sBundle);
}
void nsEudoraStringBundle::GetStringByID( PRInt32 stringID, nsString& result, nsIStringBundle *pBundle)
{
PRUnichar *ptrv = GetStringByID( stringID, pBundle);
result = ptrv;
FreeString( ptrv);
}
PRUnichar *nsEudoraStringBundle::GetStringByID(PRInt32 stringID, nsIStringBundle *pBundle)
{
PRBool mine = PR_FALSE;
if (!pBundle) {
mine = PR_TRUE;
pBundle = GetStringBundle();
}
if (pBundle) {
PRUnichar *ptrv = nsnull;
nsresult rv = pBundle->GetStringFromID(stringID, &ptrv);
if (mine) {
NS_RELEASE(pBundle);
}
if (NS_SUCCEEDED( rv) && ptrv)
return( ptrv);
}
nsString resultString( "[StringID ");
resultString.Append(stringID, 10);
resultString += "?]";
return( resultString.ToNewUnicode());
}

View File

@ -0,0 +1,46 @@
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsEudoraStringBundle_H__
#define nsEudoraStringBundle_H__
#include "nsCRT.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);
// GetStringBundle creates a new one every time!
static nsIStringBundle * GetStringBundle( void);
static void FreeString( PRUnichar *pStr) { nsCRT::free( pStr);}
};
#define EUDORAIMPORT_NAME 2000
#define EUDORAIMPORT_DESCRIPTION 2001
#define EUDORAIMPORT_MAILBOX_SUCCESS 2002
#define EUDORAIMPORT_MAILBOX_BADPARAM 2003
#define EUDORAIMPORT_MAILBOX_BADSOURCEFILE 2004
#define EUDORAIMPORT_MAILBOX_CONVERTERROR 2005
#endif /* nsEudoraStringBundle_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,84 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsEudoraWin32_h__
#define nsEudoraWin32_h__
#include "nscore.h"
#include "nsString.h"
#include "nsIFileSpec.h"
#include "nsISupportsArray.h"
#include "nsEudoraMailbox.h"
#include <windows.h>
class nsIImportService;
class nsIMsgAccountManager;
class nsIMsgAccount;
class nsEudoraWin32 : public nsEudoraMailbox {
public:
nsEudoraWin32();
~nsEudoraWin32();
// retrieve the mail folder
virtual PRBool FindMailFolder( nsIFileSpec *pFolder);
// get the list of mailboxes
virtual nsresult FindMailboxes( nsIFileSpec *pRoot, nsISupportsArray **ppArray);
// get a TOC file from a mailbox file
virtual nsresult FindTOCFile( nsIFileSpec *pMailFile, nsIFileSpec **pTOCFile, PRBool *pDeleteToc);
virtual nsresult GetAttachmentInfo( const char *pFileName, nsIFileSpec *pSpec, nsCString& mimeType);
// import settings from Win32 ini file
static PRBool ImportSettings( nsIFileSpec *pIniFile, nsIMsgAccount **localMailAccount);
static PRBool FindSettingsFile( nsIFileSpec *pIniFile) { return( FindEudoraLocation( pIniFile, PR_TRUE));}
private:
nsresult ScanMailDir( nsIFileSpec *pFolder, nsISupportsArray *pArray, nsIImportService *pImport);
nsresult IterateMailDir( nsIFileSpec *pFolder, nsISupportsArray *pArray, nsIImportService *pImport);
nsresult ScanDescmap( nsIFileSpec *pFolder, nsISupportsArray *pArray, nsIImportService *pImport, const char *pData, PRInt32 len);
nsresult FoundMailFolder( nsIFileSpec *mailFolder, const char *pName, nsISupportsArray *pArray, nsIImportService *pImport);
nsresult FoundMailbox( nsIFileSpec *mailFile, const char *pName, nsISupportsArray *pArray, nsIImportService *pImport);
PRBool FindMimeIniFile( nsIFileSpec *pSpec);
void GetMimeTypeFromExtension( nsCString& ext, nsCString& mimeType);
static PRBool FindEudoraLocation( nsIFileSpec *pFolder, PRBool findIni = PR_FALSE);
// Settings support
static PRBool BuildPOPAccount( nsIMsgAccountManager *accMgr, const char *pSection, const char *pIni, nsIMsgAccount **ppAccount);
static PRBool BuildIMAPAccount( nsIMsgAccountManager *accMgr, const char *pSection, const char *pIni, nsIMsgAccount **ppAccount);
static void GetServerAndUserName( const char *pSection, const char *pIni, nsCString& serverName, nsCString& userName, char *pBuff);
static void GetAccountName( const char *pSection, nsString& str);
static void SetIdentities( nsIMsgAccountManager *accMgr, nsIMsgAccount *acc, const char *pSection, const char *pIniFile, char *pBuff);
static void SetSmtpServer( nsIMsgAccountManager *pMgr, nsIMsgAccount *pAcc, const char *pServer, const char *pUser);
static BYTE * GetValueBytes( HKEY hKey, const char *pValueName);
private:
PRUint32 m_depth;
nsIFileSpec * m_mailImportLocation;
char * m_pMimeSection;
};
#endif /* nsEudoraWin32_h__ */

View File

@ -14,6 +14,7 @@ function ContinueMailImport() {
}
}
if (clear == true) {
dump( "Mail import finished\n");
clearInterval( intervalState);
intervalState = null;
importMailInterface = null;
@ -69,6 +70,54 @@ function test1() {
}
function eudoraMail() {
if (importMailInterface || intervalState) {
dump( "Already importing mail, wait till this one is done!\n");
return;
}
dump( "test1\n");
dump( "Loading outlook express component\n");
var module = Components.classes["component://mozilla/import/import-eudora"].createInstance();
module = module.QueryInterface(Components.interfaces.nsIImportModule);
dump( "Loaded outlook express import module\n");
dump( "Getting the mail interface\n");
var mailInterface = module.GetImportInterface( "mail");
mailInterface = mailInterface.QueryInterface( Components.interfaces.nsIImportGeneric);
dump( "Got the mail interface\n");
var loc = mailInterface.GetData( "mailLocation");
dump( "Mail location: " + loc + "\n");
if (mailInterface.WantsProgress()) {
dump( "Beginning import with progress\n");
if (mailInterface.BeginImport( null, null)) {
var count = 0;
dump( "Importing ");
importMailInterface = mailInterface;
intervalState = setInterval( "ContinueMailImport()", 100);
dump( "\nWaiting for import to finish.....\n");
}
else {
dump( "BeginImport returned failure\n");
}
}
else {
if (mailInterface.BeginImport( null, null)) {
dump( "BeginImport successful without progress\n");
}
else {
dump( "BeginImport FAILED without progress\n");
}
}
}
function test2() {
dump( "test2\n");
@ -147,7 +196,8 @@ function test3() {
<form name="form">
<input type="button" value="Import Outlook Express Mail" onclick="test1();"><br>
<input type="button" value="Import Outlook Express Address Book" onclick="test2();"><br>
<input type="button" value="Import Outlook Express Settings" onclick="test3();">
<input type="button" value="Import Outlook Express Settings" onclick="test3();"><br>
<input type="button" value="Import Eudora Mail" onclick="eudoraMail();">
<form>
</body>

View File

@ -785,6 +785,8 @@ ImportMailThread( void *stuff)
pData->abort = PR_TRUE;
}
IMPORT_LOG1( "Total number of mailboxes: %d\n", (int) count);
for (i = 0; (i < count) && !(pData->abort); i++) {
pSupports = pData->boxes->ElementAt( i);
if (pSupports) {
@ -900,6 +902,7 @@ ImportMailThread( void *stuff)
pData->currentSize = 0;
pData->currentTotal += size;
if (fatalError) {
IMPORT_LOG1( "*** ImportMailbox returned fatalError, mailbox #%d\n", (int) i);
pData->fatalError = PR_TRUE;
break;
}
@ -911,7 +914,10 @@ ImportMailThread( void *stuff)
nsImportGenericMail::SetLogs( success, error, pData->successLog, pData->errorLog);
if (pData->abort || pData->fatalError) {
IMPORT_LOG0( "Abort or fatalError set\n");
if (pData->ownsDestRoot) {
IMPORT_LOG0( "Calling destRoot->RecursiveDelete\n");
destRoot->RecursiveDelete( PR_TRUE);
}
else {
@ -919,7 +925,10 @@ ImportMailThread( void *stuff)
}
}
IMPORT_LOG1( "Import mailbox thread done: %d\n", (int) pData->currentTotal);
pData->ThreadDelete();
}

View File

@ -0,0 +1,55 @@
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#
#
# The following are used by the outlook express import code to display status/error
# and informational messages
#
# Short name of import module
## @name EUDORAIMPORT_NAME
## @loc None
2000=Eudora
# Description of import module
## @name EUDORAIMPORT_DESCRIPTION
## @loc None
2001=Eudora mail and address books
# Success message
## @name EUDORAIMPORT_MAILBOX_SUCCESS
## @loc None
2002=Mailbox %S, imported %d messages
# Error message
## @name EUDORAIMPORT_MAILBOX_BADPARAM
## @loc None
2003=Bad parameter passed to import mailbox.
# Error message
## @name EUDORAIMPORT_MAILBOX_BADSOURCEFILE
## @loc None
2004=Error accessing file for mailbox %S.
# Error message
## @name EUDORAIMPORT_MAILBOX_CONVERTERROR
## @loc None
2005=Error importing mailbox %S, all messages may not be imported from this mailbox.