landing movemail changes from adam@gimp.org. only builds on UNIX, no extra bloat for win32 or mac. r=sspitzer@netscape.com

This commit is contained in:
sspitzer%netscape.com 2000-10-14 21:21:15 +00:00
Родитель 53f795f4c8
Коммит c634ddf44c
18 изменённых файлов: 892 добавлений и 20 удалений

Просмотреть файл

@ -3974,6 +3974,8 @@ fi
AC_DEFINE(JS_THREADSAFE)
AC_DEFINE(LAYERS)
AC_DEFINE(HAVE_MOVEMAIL)
# Used for LD_LIBRARY_PATH of run_viewer target
LIBS_PATH=

Просмотреть файл

@ -1186,9 +1186,11 @@ nsMessengerMigrator::MigrateMovemailAccount(nsIMsgIdentity *identity)
rv = m_prefs->CopyCharPref(PREF_4X_MAIL_POP_NAME, getter_Copies(username));
if (NS_FAILED(rv)) return rv;
// for right now, use "none". eventually, we'll have "movemail"
//
// create the server
//
rv = accountManager->CreateIncomingServer(username, MOVEMAIL_FAKE_HOST_NAME,
"none", getter_AddRefs(server));
"movemail", getter_AddRefs(server));
if (NS_FAILED(rv)) return rv;
// create the identity

Просмотреть файл

@ -65,10 +65,6 @@
#endif /* XP_UNIX || XP_BEOS */
#ifdef XP_UNIX
#define HAVE_MOVEMAIL 1
#endif /* HAVE_MOVEMAIL */
class nsMessengerMigrator
: public nsIMessengerMigrator, public nsIObserver
{

Просмотреть файл

@ -18,6 +18,7 @@
* Rights Reserved.
*
* Contributor(s):
* Adam D. Moss <adam@gimp.org>
*/
#ifndef nsMsgLocalCID_h__
@ -54,6 +55,20 @@
0xd2876e51, 0xe62c, 0x11d2, \
{0xb7, 0xfc, 0x0, 0x80, 0x5f, 0x5, 0xff, 0xa5 }}
#ifdef HAVE_MOVEMAIL
//
// nsMovemailIncomingServer
//
#define NS_MOVEMAILINCOMINGSERVER_CONTRACTID \
NS_MSGINCOMINGSERVER_CONTRACTID_PREFIX "movemail"
#define NS_MOVEMAILINCOMINGSERVER_CID \
{ /* efbb77e4-1dd2-11b2-bbcf-961563396fec */ \
0xefbb77e4, 0x1dd2, 0x11b2, \
{0xbb, 0xcf, 0x96, 0x15, 0x63, 0x39, 0x6f, 0xec }}
#endif /* HAVE_MOVEMAIL */
//
// nsNoIncomingServer
//
@ -143,6 +158,23 @@
0x75b63b46, 0x1dd2, 0x11b2, \
{ 0x98, 0x73, 0xbb, 0x37, 0x5e, 0x15, 0x50, 0xfa }}
#ifdef HAVE_MOVEMAIL
//
// nsMovemailService
//
#define NS_MOVEMAILSERVICE_CONTRACTID \
"component://netscape/messenger/movemailservice"
#define NS_MOVEMAILPROTOCOLINFO_CONTRACTID \
NS_MSGPROTOCOLINFO_CONTRACTID_PREFIX "movemail"
#define NS_MOVEMAILSERVICE_CID \
{ /* 0e4db62e-1dd2-11b2-a5e4-f128fe4f1b69 */ \
0x0e4db62e, 0x1dd2, 0x11b2, \
{ 0xa5, 0xe4, 0xf1, 0x28, 0xfe, 0x4f, 0x1b, 0x69 }}
#endif /* HAVE_MOVEMAIL */
//
// nsParseMailMsgState
//

Просмотреть файл

@ -19,6 +19,7 @@
*
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.com>
* Adam D. Moss <adam@gimp.org>
*/
#include "msgCore.h" // for pre-compiled headers...
@ -33,6 +34,10 @@
#include "nsLocalMailFolder.h"
#include "nsParseMailbox.h"
#include "nsPop3Service.h"
#ifdef HAVE_MOVEMAIL
#include "nsMovemailService.h"
#include "nsMovemailIncomingServer.h"
#endif /* HAVE_MOVEMAIL */
#include "nsNoneService.h"
#include "nsPop3IncomingServer.h"
#include "nsNoIncomingServer.h"
@ -44,6 +49,10 @@ static NS_DEFINE_CID(kMailboxParserCID, NS_MAILBOXPARSER_CID);
static NS_DEFINE_CID(kMailboxServiceCID, NS_MAILBOXSERVICE_CID);
static NS_DEFINE_CID(kLocalMailFolderResourceCID, NS_LOCALMAILFOLDERRESOURCE_CID);
static NS_DEFINE_CID(kPop3ServiceCID, NS_POP3SERVICE_CID);
#ifdef HAVE_MOVEMAIL
static NS_DEFINE_CID(kMovemailServiceCID, NS_MOVEMAILSERVICE_CID);
static NS_DEFINE_CID(kMovemailIncomingServerCID, NS_MOVEMAILINCOMINGSERVER_CID);
#endif /* HAVE_MOVEMAIL */
static NS_DEFINE_CID(kNoneServiceCID, NS_NONESERVICE_CID);
static NS_DEFINE_CID(kPop3UrlCID, NS_POP3URL_CID);
static NS_DEFINE_CID(kPop3IncomingServerCID, NS_POP3INCOMINGSERVER_CID);
@ -59,10 +68,16 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsPop3URL)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgMailboxParser)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMailboxService)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPop3Service)
#ifdef HAVE_MOVEMAIL
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMovemailService)
#endif /* HAVE_MOVEMAIL */
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNoneService)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgLocalMailFolder)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsParseMailMessageState)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPop3IncomingServer)
#ifdef HAVE_MOVEMAIL
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMovemailIncomingServer)
#endif /* HAVE_MOVEMAIL */
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNoIncomingServer)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsLocalStringService)
@ -88,10 +103,16 @@ protected:
nsCOMPtr<nsIGenericFactory> mMailboxParserFactory;
nsCOMPtr<nsIGenericFactory> mMailboxServiceFactory;
nsCOMPtr<nsIGenericFactory> mPop3ServiceFactory;
#ifdef HAVE_MOVEMAIL
nsCOMPtr<nsIGenericFactory> mMovemailServiceFactory;
#endif /* HAVE_MOVEMAIL */
nsCOMPtr<nsIGenericFactory> mNoneServiceFactory;
nsCOMPtr<nsIGenericFactory> mLocalMailFolderFactory;
nsCOMPtr<nsIGenericFactory> mParseMailMsgStateFactory;
nsCOMPtr<nsIGenericFactory> mPop3IncomingServerFactory;
#ifdef HAVE_MOVEMAIL
nsCOMPtr<nsIGenericFactory> mMovemailIncomingServerFactory;
#endif /* HAVE_MOVEMAIL */
nsCOMPtr<nsIGenericFactory> mNoIncomingServerFactory;
nsCOMPtr<nsIGenericFactory> mLocalStringBundleFactory;
};
@ -129,10 +150,16 @@ void nsMsgLocalModule::Shutdown()
mMailboxParserFactory = null_nsCOMPtr();
mMailboxServiceFactory = null_nsCOMPtr();
mPop3ServiceFactory = null_nsCOMPtr();
#ifdef HAVE_MOVEMAIL
mMovemailServiceFactory = null_nsCOMPtr();
#endif /* HAVE_MOVEMAIL */
mNoneServiceFactory = null_nsCOMPtr();
mLocalMailFolderFactory = null_nsCOMPtr();
mParseMailMsgStateFactory = null_nsCOMPtr();
mPop3IncomingServerFactory = null_nsCOMPtr();
#ifdef HAVE_MOVEMAIL
mMovemailIncomingServerFactory = null_nsCOMPtr();
#endif /* HAVE_MOVEMAIL */
mNoIncomingServerFactory = null_nsCOMPtr();
mLocalStringBundleFactory = null_nsCOMPtr();
}
@ -193,6 +220,14 @@ NS_IMETHODIMP nsMsgLocalModule::GetClassObject(nsIComponentManager *aCompMgr,
rv = NS_NewGenericFactory(getter_AddRefs(mPop3ServiceFactory), &nsPop3ServiceConstructor);
fact = mPop3ServiceFactory;
}
#ifdef HAVE_MOVEMAIL
else if (aClass.Equals(kMovemailServiceCID))
{
if (!mMovemailServiceFactory)
rv = NS_NewGenericFactory(getter_AddRefs(mMovemailServiceFactory), &nsMovemailServiceConstructor);
fact = mMovemailServiceFactory;
}
#endif /* HAVE_MOVEMAIL */
else if (aClass.Equals(kNoneServiceCID))
{
if (!mNoneServiceFactory)
@ -217,6 +252,14 @@ NS_IMETHODIMP nsMsgLocalModule::GetClassObject(nsIComponentManager *aCompMgr,
rv = NS_NewGenericFactory(getter_AddRefs(mPop3IncomingServerFactory), &nsPop3IncomingServerConstructor);
fact = mPop3IncomingServerFactory;
}
#ifdef HAVE_MOVEMAIL
else if (aClass.Equals(kMovemailIncomingServerCID))
{
if (!mMovemailIncomingServerFactory)
rv = NS_NewGenericFactory(getter_AddRefs(mMovemailIncomingServerFactory), &nsMovemailIncomingServerConstructor);
fact = mMovemailIncomingServerFactory;
}
#endif /* HAVE_MOVEMAIL */
else if (aClass.Equals(kNoIncomingServerCID))
{
if (!mNoIncomingServerFactory)
@ -264,14 +307,26 @@ static Components gComponents[] = {
NS_POP3SERVICE_CONTRACTID2 },
{ "None Service", &kNoneServiceCID,
NS_NONESERVICE_CONTRACTID },
#ifdef HAVE_MOVEMAIL
{ "Movemail Service", &kMovemailServiceCID,
NS_MOVEMAILSERVICE_CONTRACTID },
#endif /* HAVE_MOVEMAIL */
{ "pop3 Protocol Information", &kPop3ServiceCID,
NS_POP3PROTOCOLINFO_CONTRACTID },
{ "none Protocol Information", &kNoneServiceCID,
NS_NONEPROTOCOLINFO_CONTRACTID },
#ifdef HAVE_MOVEMAIL
{ "movemail Protocol Information", &kMovemailServiceCID,
NS_MOVEMAILPROTOCOLINFO_CONTRACTID },
#endif /* HAVE_MOVEMAIL */
{ "Local Mail Folder Resource Factory", &kLocalMailFolderResourceCID,
NS_LOCALMAILFOLDERRESOURCE_CONTRACTID },
{ "Pop3 Incoming Server", &kPop3IncomingServerCID,
NS_POP3INCOMINGSERVER_CONTRACTID },
#ifdef HAVE_MOVEMAIL
{ "Movemail Incoming Server", &kMovemailIncomingServerCID,
NS_MOVEMAILINCOMINGSERVER_CONTRACTID },
#endif /* HAVE_MOVEMAIL */
{ "No Incoming Server", &kNoIncomingServerCID,
NS_NOINCOMINGSERVER_CONTRACTID },
{ "Parse MailMessage State", &kParseMailMsgStateCID,

Просмотреть файл

@ -38,7 +38,9 @@ XPIDLSRCS = \
nsIMsgParseMailMsgState.idl \
nsINoIncomingServer.idl \
nsINoneService.idl \
nsIMsgLocalMailFolder.idl \
nsIMovemailService.idl \
nsIMovemailIncomingServer.idl \
nsIMsgLocalMailFolder.idl \
nsILocalMailIncomingServer.idl \
$(NULL)

Просмотреть файл

@ -0,0 +1,30 @@
/* -*- Mode: IDL; 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.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/NPL/
*
* 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Adam D. Moss <adam@gimp.org>
*/
#include "nsISupports.idl"
#include "nsIFileSpec.idl"
[scriptable, uuid(0dbfa510-1dd2-11b2-9f0e-849c5a241ab6)]
interface nsIMovemailIncomingServer : nsISupports {
};

Просмотреть файл

@ -0,0 +1,41 @@
/* -*- 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.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/NPL/
*
* 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Seth Spitzer <sspitzer@netscape.com>
* Adam D. Moss <adam@gimp.org>
*/
#include "nsISupports.idl"
#include "nsIUrlListener.idl"
#include "nsIMovemailIncomingServer.idl"
#include "nsIMsgFolder.idl"
[scriptable, uuid(4c7786a4-1dd2-11b2-9fbe-c59d742de59b)]
interface nsIMovemailService : nsISupports {
nsIURI GetNewMail(in nsIMsgWindow aMsgWindow,
in nsIUrlListener aUrlListener,
in nsIMsgFolder aMsgFolder,
in nsIMovemailIncomingServer movemailServer);
nsIURI CheckForNewMail(in nsIUrlListener aUrlListener,
in nsIMsgFolder inbox,
in nsIMovemailIncomingServer movemailServer);
};

Просмотреть файл

@ -45,7 +45,9 @@ CPPSRCS = \
nsLocalUndoTxn.cpp \
nsLocalStringBundle.cpp \
nsNoIncomingServer.cpp \
nsNoneService.cpp \
nsMovemailIncomingServer.cpp \
nsNoneService.cpp \
nsMovemailService.cpp \
$(NULL)
EXPORTS = \

Просмотреть файл

@ -55,8 +55,14 @@
#include "nsMsgUtils.h"
#include "nsLocalUtils.h"
#include "nsIPop3IncomingServer.h"
#ifdef HAVE_MOVEMAIL
#include "nsMovemailIncomingServer.h"
#endif /* HAVE_MOVEMAIL */
#include "nsILocalMailIncomingServer.h"
#include "nsIPop3Service.h"
#ifdef HAVE_MOVEMAIL
#include "nsIMovemailService.h"
#endif /* HAVE_MOVEMAIL */
#include "nsIMsgIncomingServer.h"
#include "nsMsgBaseCID.h"
#include "nsMsgLocalCID.h"
@ -82,6 +88,9 @@ static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kMailboxServiceCID, NS_MAILBOXSERVICE_CID);
static NS_DEFINE_CID(kCMailDB, NS_MAILDB_CID);
static NS_DEFINE_CID(kCPop3ServiceCID, NS_POP3SERVICE_CID);
#ifdef HAVE_MOVEMAIL
static NS_DEFINE_CID(kCMovemailServiceCID, NS_MOVEMAILSERVICE_CID);
#endif /* HAVE_MOVEMAIL */
static NS_DEFINE_CID(kCopyMessageStreamListenerCID, NS_COPYMESSAGESTREAMLISTENER_CID);
static NS_DEFINE_CID(kMsgCopyServiceCID, NS_MSGCOPYSERVICE_CID);
static NS_DEFINE_CID(kStandardUrlCID, NS_STANDARDURL_CID);
@ -2863,6 +2872,18 @@ nsMsgLocalMailFolder::GetIncomingServerType()
return mType;
}
#ifdef HAVE_MOVEMAIL
// next try "movemail"
rv = accountManager->FindServer(userName,
hostName,
"movemail",
getter_AddRefs(server));
if (NS_SUCCEEDED(rv) && server) {
mType = "movemail";
return mType;
}
#endif /* HAVE_MOVEMAIL */
return "";
}

Просмотреть файл

@ -64,6 +64,20 @@ nsGetMailboxServer(const char *username, const char *hostname, nsIMsgIncomingSer
return rv;
}
#ifdef HAVE_MOVEMAIL
// find all movemail "servers" matching the given hostname
nsCOMPtr<nsIMsgIncomingServer> movemail_server;
rv = accountManager->FindServer(username,
hostname,
"movemail",
getter_AddRefs(movemail_server));
if (NS_SUCCEEDED(rv)) {
*aResult = movemail_server;
NS_ADDREF(*aResult);
return rv;
}
#endif /* HAVE_MOVEMAIL */
// if that fails, look for the pop hosts matching the given hostname
nsCOMPtr<nsIMsgIncomingServer> pop3_server;
if (NS_FAILED(rv)) {
@ -78,7 +92,7 @@ nsGetMailboxServer(const char *username, const char *hostname, nsIMsgIncomingSer
}
}
// if you fail after looking at all "pop3" and all "none" servers, you fail.
// if you fail after looking at all "pop3", "movemail" and "none" servers, you fail.
return rv;
}
@ -86,7 +100,6 @@ static nsresult
nsLocalURI2Server(const char* uriStr,
nsIMsgIncomingServer ** aResult)
{
nsresult rv;
// start parsing the uriStr
@ -169,7 +182,7 @@ nsLocalURI2Path(const char* rootURI, const char* uriStr,
nsCOMPtr<nsIMsgIncomingServer> server;
rv = nsLocalURI2Server(uriStr, getter_AddRefs(server));
if (NS_FAILED(rv))
return rv;
@ -191,7 +204,7 @@ nsLocalURI2Path(const char* rootURI, const char* uriStr,
nsAutoString sbdSep;
rv = nsGetMailFolderSeparator(sbdSep);
nsCAutoString newPath("");
char *unescaped = nsCRT::strdup(curPos);
// Unescape folder name
@ -205,6 +218,7 @@ nsLocalURI2Path(const char* rootURI, const char* uriStr,
pathResult+=newPath.GetBuffer();
}
return NS_OK;
}

Просмотреть файл

@ -0,0 +1,182 @@
/* -*- 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.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/NPL/
*
* 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Adam D. Moss <adam@gimp.org>
*/
#include "prmem.h"
#include "plstr.h"
#include "prprf.h"
//#include "nsCOMPtr.h"
//#include "nsIPref.h"
#include "nsXPIDLString.h"
#include "nsMsgLocalCID.h"
#include "nsMsgFolderFlags.h"
#include "nsIFileSpec.h"
#include "nsIPref.h"
#include "nsIMsgLocalMailFolder.h"
#include "nsIMovemailService.h"
#include "msgCore.h" // pre-compiled headers
#include "nsMovemailIncomingServer.h"
static NS_DEFINE_CID(kCMovemailServiceCID, NS_MOVEMAILSERVICE_CID);
NS_IMPL_ISUPPORTS_INHERITED2(nsMovemailIncomingServer,
nsMsgIncomingServer,
nsIMovemailIncomingServer,
nsILocalMailIncomingServer)
nsMovemailIncomingServer::nsMovemailIncomingServer()
{
NS_INIT_REFCNT();
}
nsMovemailIncomingServer::~nsMovemailIncomingServer()
{
}
/*NS_IMPL_SERVERPREF_BOOL(nsMovemailIncomingServer,
AdamIsASillyhead,
"adam_is_a_sillyhead")*/
nsresult
nsMovemailIncomingServer::GetLocalStoreType(char **type)
{
NS_ENSURE_ARG_POINTER(type);
*type = nsCRT::strdup("mailbox");
return NS_OK;
}
NS_IMETHODIMP
nsMovemailIncomingServer::SetFlagsOnDefaultMailboxes()
{
nsresult rv;
nsCOMPtr<nsIFolder> rootFolder;
rv = GetRootFolder(getter_AddRefs(rootFolder));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIMsgLocalMailFolder> localFolder =
do_QueryInterface(rootFolder, &rv);
NS_ENSURE_SUCCESS(rv, rv);
localFolder->SetFlagsOnDefaultMailboxes(MSG_FOLDER_FLAG_INBOX |
MSG_FOLDER_FLAG_SENTMAIL |
MSG_FOLDER_FLAG_DRAFTS |
MSG_FOLDER_FLAG_TEMPLATES |
MSG_FOLDER_FLAG_TRASH |
// hmm?
MSG_FOLDER_FLAG_QUEUE);
return NS_OK;
}
NS_IMETHODIMP nsMovemailIncomingServer::CreateDefaultMailboxes(nsIFileSpec *path)
{
nsresult rv;
PRBool exists;
if (!path) return NS_ERROR_NULL_POINTER;
// todo, use a string bundle for this
rv =path->AppendRelativeUnixPath("Inbox");
if (NS_FAILED(rv)) return rv;
rv = path->Exists(&exists);
if (!exists) {
rv = path->Touch();
if (NS_FAILED(rv)) return rv;
}
rv =path->SetLeafName("Trash");
if (NS_FAILED(rv)) return rv;
rv = path->Exists(&exists);
if (!exists) {
rv = path->Touch();
if (NS_FAILED(rv)) return rv;
}
rv = path->SetLeafName("Sent");
if (NS_FAILED(rv)) return rv;
rv = path->Exists(&exists);
if (NS_FAILED(rv)) return rv;
if (!exists) {
rv = path->Touch();
if (NS_FAILED(rv)) return rv;
}
rv = path->SetLeafName("Drafts");
if (NS_FAILED(rv)) return rv;
rv = path->Exists(&exists);
if (NS_FAILED(rv)) return rv;
if (!exists) {
rv = path->Touch();
if (NS_FAILED(rv)) return rv;
}
rv = path->SetLeafName("Templates");
if (NS_FAILED(rv)) return rv;
rv = path->Exists(&exists);
if (NS_FAILED(rv)) return rv;
if (!exists) {
rv = path->Touch();
if (NS_FAILED(rv)) return rv;
}
rv = path->SetLeafName("Unsent Messages");
if (NS_FAILED(rv)) return rv;
rv = path->Exists(&exists);
if (NS_FAILED(rv)) return rv;
if (!exists) {
rv = path->Touch();
if (NS_FAILED(rv)) return rv;
}
return rv;
}
NS_IMETHODIMP
nsMovemailIncomingServer::GetNewMail(nsIMsgWindow *aMsgWindow,
nsIUrlListener *aUrlListener,
nsIMsgFolder *aMsgFolder,
nsIURI **aResult)
{
nsresult rv;
NS_WITH_SERVICE(nsIMovemailService, movemailService,
kCMovemailServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = movemailService->GetNewMail(aMsgWindow, aUrlListener,
aMsgFolder, this, aResult);
return rv;
}

Просмотреть файл

@ -0,0 +1,50 @@
/* -*- 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.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/NPL/
*
* 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Adam D. Moss <adam@gimp.org>
*/
#ifndef __nsMovemailIncomingServer_h
#define __nsMovemailIncomingServer_h
#include "msgCore.h"
#include "nsIMovemailIncomingServer.h"
#include "nsILocalMailIncomingServer.h"
#include "nsMsgIncomingServer.h"
/* get some implementation from nsMsgIncomingServer */
class nsMovemailIncomingServer : public nsMsgIncomingServer,
public nsIMovemailIncomingServer,
public nsILocalMailIncomingServer
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIMOVEMAILINCOMINGSERVER
NS_DECL_NSILOCALMAILINCOMINGSERVER
nsMovemailIncomingServer();
virtual ~nsMovemailIncomingServer();
NS_IMETHOD GetLocalStoreType(char * *type);
};
#endif

Просмотреть файл

@ -0,0 +1,396 @@
/* -*- 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.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/NPL/
*
* 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Seth Spitzer <sspitzer@netscape.com>
* Adam D. Moss <adam@gimp.org>
*/
#include "prenv.h"
#include "msgCore.h" // precompiled header...
#include "nsMovemailService.h"
#include "nsIMovemailService.h"
#include "nsIMsgIncomingServer.h"
#include "nsIMovemailIncomingServer.h"
#include "nsIMsgProtocolInfo.h"
#include "nsIMsgMailSession.h"
#include "nsParseMailbox.h"
#include "nsIFolder.h"
#include "nsFileSpec.h"
#include "nsFileStream.h"
#include "nsIPref.h"
#include "nsMsgLocalCID.h"
#include "nsMsgBaseCID.h"
#include "nsXPIDLString.h"
#include "nsCOMPtr.h"
#include "nsIFileLocator.h"
#include "nsFileLocations.h"
#define PREF_MAIL_ROOT_MOVEMAIL "mail.root.movemail"
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
static NS_DEFINE_CID(kMsgMailSessionCID, NS_MSGMAILSESSION_CID);
static NS_DEFINE_IID(kIFileLocatorIID, NS_IFILELOCATOR_IID);
static NS_DEFINE_CID(kFileLocatorCID, NS_FILELOCATOR_CID);
nsMovemailService::nsMovemailService()
{
NS_INIT_REFCNT();
//fprintf(stderr, "*** MURRR, new nsMovemailService\n");
}
nsMovemailService::~nsMovemailService()
{}
NS_IMPL_ISUPPORTS2(nsMovemailService,
nsIMovemailService,
nsIMsgProtocolInfo)
NS_IMETHODIMP
nsMovemailService::CheckForNewMail(nsIUrlListener * aUrlListener,
nsIMsgFolder *inbox,
nsIMovemailIncomingServer *movemailServer,
nsIURI ** aURL)
{
nsresult rv = NS_OK;
//fprintf(stderr, "*** WOOWOOWOO check\n");
return rv;
}
// one day we will do mail file locking right here.
nsInputFileStream * Probe_SpoolFilePath(const char *pathStr)
{
if (!pathStr) return nsnull;
nsInputFileStream * rtnStream = nsnull;
nsFileSpec * filespec = new nsFileSpec(pathStr);
if (!filespec)
return nsnull;
if (!filespec->Failed() &&
filespec->IsFile())
{
// fprintf(stderr, "##%s##", filespec->GetLeafName());
rtnStream = new nsInputFileStream (*filespec);
if (rtnStream) {
if (rtnStream->failed() ||
!rtnStream->is_open()) {
delete rtnStream;
rtnStream = nsnull;
}
}
}
delete filespec;
return rtnStream;
}
nsresult
nsMovemailService::GetNewMail(nsIMsgWindow *aMsgWindow,
nsIUrlListener *aUrlListener,
nsIMsgFolder *aMsgFolder,
nsIMovemailIncomingServer *movemailServer,
nsIURI ** aURL)
{
nsresult rv = NS_OK;
nsCOMPtr<nsIMsgIncomingServer> in_server = do_QueryInterface(movemailServer);
nsCAutoString wholeboxname;
if (in_server) {
nsCOMPtr<nsIFileSpec> mailDirectory;
in_server->SetServerBusy(PR_TRUE);
rv = in_server->GetLocalPath(getter_AddRefs(mailDirectory));
// FUN STUFF starts here
{
// we now quest for the mail spool file...
nsInputFileStream * spoolfile = nsnull;
// If $(MAIL) is set then we have things easy.
char * wholeboxname_from_env = PR_GetEnv("MAIL");
if (wholeboxname_from_env) {
wholeboxname.Assign(wholeboxname_from_env);
spoolfile = Probe_SpoolFilePath(wholeboxname_from_env);
} else {
// Otherwise try to build the mailbox path from the
// username and a number of guessed spool directory
// paths.
char * boxfilename;
boxfilename = PR_GetEnv("USER"); // UNIXy
if (!boxfilename) {
boxfilename = PR_GetEnv("USERNAME"); // WIN32 (!)
}
if (boxfilename) {
// We have the username which is probably also the
// mailbox file name, so now try to find the mailbox
// in a number of likely places.
wholeboxname = "/var/spool/mail/";
wholeboxname += boxfilename;
spoolfile = Probe_SpoolFilePath((const char *)wholeboxname);
if (!spoolfile) {
wholeboxname = "/usr/spool/mail/";
wholeboxname += boxfilename;
spoolfile = Probe_SpoolFilePath((const char *)wholeboxname);
}
if (!spoolfile) {
wholeboxname = "/var/mail/";
wholeboxname += boxfilename;
spoolfile = Probe_SpoolFilePath((const char *)wholeboxname);
}
if (!spoolfile) {
wholeboxname = "/usr/mail/";
wholeboxname += boxfilename;
spoolfile = Probe_SpoolFilePath((const char *)wholeboxname);
}
}
}
if (!spoolfile) {
//fprintf(stderr, "Nope, no luck getting spool file name at all.\n");
return NS_ERROR_FAILURE;
}
#define READBUFSIZE 4096
char * buffer = (char*)PR_CALLOC(READBUFSIZE);
if (buffer) {
if (!spoolfile->failed()) {
nsresult rv;
nsIOFileStream* m_outFileStream;
nsParseNewMailState *m_newMailParser;
nsCOMPtr<nsIFileSpec> mailDirectory;
rv = in_server->GetLocalPath(getter_AddRefs(mailDirectory));
if (NS_FAILED(rv)) return rv;
nsFileSpec fileSpec;
mailDirectory->GetFileSpec(&fileSpec);
fileSpec += "Inbox";
m_outFileStream = new nsIOFileStream(fileSpec /*, PR_CREATE_FILE */);
if (m_outFileStream)
m_outFileStream->seek(fileSpec.GetFileSize());
else
return NS_ERROR_UNEXPECTED;
// create a new mail parser
m_newMailParser = new nsParseNewMailState;
if (m_newMailParser == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr <nsIFolder> serverFolder;
rv = in_server->GetRootFolder(getter_AddRefs(serverFolder));
if (NS_FAILED(rv))
return rv;
rv = m_newMailParser->Init(serverFolder, fileSpec, m_outFileStream);
if (NS_FAILED(rv))
return rv;
// MIDDLE of the FUN : consume the mailbox data.
{
int numlines = 0;
while (!spoolfile->eof() &&
!spoolfile->failed() &&
spoolfile->is_open())
{
spoolfile->readline(buffer,
READBUFSIZE-(1+PL_strlen(MSG_LINEBREAK)));
PL_strcpy(&buffer[PL_strlen(buffer)], MSG_LINEBREAK);
// fprintf(stderr, "%d: %s", numlines, buffer);
if ((numlines>0) &&
nsCRT::strncmp(buffer, "From ", 5) == 0) {
numlines = 0;
}
m_newMailParser->HandleLine(buffer, PL_strlen(buffer));
*m_outFileStream << buffer;
numlines++;
if (numlines == 1) {
PL_strcpy(buffer, "X-Mozilla-Status: 8000"
MSG_LINEBREAK);
m_newMailParser->HandleLine(buffer,
PL_strlen(buffer));
*m_outFileStream << buffer;
PL_strcpy(buffer, "X-Mozilla-Status2: 00000000"
MSG_LINEBREAK);
m_newMailParser->HandleLine(buffer,
PL_strlen(buffer));
*m_outFileStream << buffer;
}
}
}
// END
m_outFileStream->flush(); // try this.
m_newMailParser->OnStopRequest(nsnull, nsnull, NS_OK, nsnull);
delete m_outFileStream;
m_outFileStream = 0;
delete m_newMailParser;
// truncate the spool file here.
nsFileSpec * filespecForTrunc = new nsFileSpec((const char *)wholeboxname);
if (filespecForTrunc) {
filespecForTrunc->Truncate(0);
delete filespecForTrunc;
filespecForTrunc = nsnull;
}
delete spoolfile;
}
PR_Free(buffer);
}
}
in_server->SetServerBusy(PR_FALSE);
} else {
//fprintf(stderr, "*** NONONO get:noserv\n");
}
//fprintf(stderr, "*** YEAHYEAHYEAH get\n");
return rv;
}
NS_IMETHODIMP
nsMovemailService::SetDefaultLocalPath(nsIFileSpec *aPath)
{
nsresult rv;
NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = prefs->SetFilePref(PREF_MAIL_ROOT_MOVEMAIL, aPath, PR_FALSE /* set default */);
return rv;
}
NS_IMETHODIMP
nsMovemailService::GetDefaultLocalPath(nsIFileSpec ** aResult)
{
nsresult rv;
NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = prefs->GetFilePref(PREF_MAIL_ROOT_MOVEMAIL, aResult);
if (NS_SUCCEEDED(rv)) return rv;
NS_WITH_SERVICE(nsIFileLocator, locator, kFileLocatorCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = locator->GetFileLocation(nsSpecialFileSpec::App_MailDirectory50, aResult);
if (NS_FAILED(rv)) return rv;
rv = SetDefaultLocalPath(*aResult);
return rv;
}
NS_IMETHODIMP
nsMovemailService::GetServerIID(nsIID* *aServerIID)
{
*aServerIID = new nsIID(NS_GET_IID(nsIMovemailIncomingServer));
return NS_OK;
}
NS_IMETHODIMP
nsMovemailService::GetRequiresUsername(PRBool *aRequiresUsername)
{
NS_ENSURE_ARG_POINTER(aRequiresUsername);
//fprintf(stderr, ">>> Yah, got asked for info\n");
*aRequiresUsername = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsMovemailService::GetPreflightPrettyNameWithEmailAddress(PRBool *aPreflightPrettyNameWithEmailAddress)
{
NS_ENSURE_ARG_POINTER(aPreflightPrettyNameWithEmailAddress);
*aPreflightPrettyNameWithEmailAddress = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP
nsMovemailService::GetCanDelete(PRBool *aCanDelete)
{
NS_ENSURE_ARG_POINTER(aCanDelete);
*aCanDelete = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsMovemailService::GetCanDuplicate(PRBool *aCanDuplicate)
{
NS_ENSURE_ARG_POINTER(aCanDuplicate);
*aCanDuplicate = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsMovemailService::GetDefaultCopiesAndFoldersPrefsToServer(PRBool *aDefaultCopiesAndFoldersPrefsToServer)
{
NS_ENSURE_ARG_POINTER(aDefaultCopiesAndFoldersPrefsToServer);
// when a "movemail" server is created (like "Local Folders")
// the copies and folder prefs for the associated identity
// point to folders on this server.
*aDefaultCopiesAndFoldersPrefsToServer = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP
nsMovemailService::GetDefaultServerPort(PRInt32 *aDefaultPort)
{
NS_ASSERTION(0, "This should probably never be called!");
NS_ENSURE_ARG_POINTER(aDefaultPort);
*aDefaultPort = -1;
return NS_OK;
}

Просмотреть файл

@ -0,0 +1,51 @@
/* -*- 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.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/NPL/
*
* 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Seth Spitzer <sspitzer@netscape.com>
* Adam D. Moss <adam@gimp.org>
*/
#ifndef nsMovemailService_h___
#define nsMovemailService_h___
#include "nscore.h"
#include "nsIMovemailService.h"
#include "nsFileSpec.h"
#include "nsIMsgProtocolInfo.h"
class nsParseNewMailState;
class nsIFolder;
class nsMovemailService : public nsIMsgProtocolInfo, public nsIMovemailService
{
public:
nsMovemailService();
virtual ~nsMovemailService();
NS_DECL_ISUPPORTS
// NS_DECL_ISUbleh
NS_DECL_NSIMOVEMAILSERVICE
NS_DECL_NSIMSGPROTOCOLINFO
};
#endif /* nsMovemailService_h___ */

Просмотреть файл

@ -57,9 +57,9 @@ PRUnichar *nsPop3IncomingServer::kTemplatesName = 0;
PRUnichar *nsPop3IncomingServer::kUnsentName = 0;
NS_IMPL_ISUPPORTS_INHERITED2(nsPop3IncomingServer,
nsMsgIncomingServer,
nsIPop3IncomingServer,
nsILocalMailIncomingServer)
nsMsgIncomingServer,
nsIPop3IncomingServer,
nsILocalMailIncomingServer)
nsPop3IncomingServer::nsPop3IncomingServer()
{

Просмотреть файл

@ -2938,7 +2938,7 @@ nsresult nsPop3Protocol::ProcessProtocolState(nsIURI * url, nsIInputStream * aIn
{
nsCOMPtr<nsIMsgIncomingServer> server = do_QueryInterface(m_pop3Server);
if (server)
server->SetServerBusy(PR_FALSE); // the server is now busy
server->SetServerBusy(PR_FALSE); // the server is now not busy
}
CloseSocket();

Просмотреть файл

@ -787,8 +787,6 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
#ifdef HAVE_MOVEMAIL
else if (serverType == MOVEMAIL_4X_MAIL_TYPE) {
printf("sorry, movemail not supported yet.\n");
summaryMailDriveDefault = PR_TRUE;
summaryMailDrive = profileDrive;
@ -1021,8 +1019,6 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
#ifdef HAVE_MOVEMAIL
else if (serverType == MOVEMAIL_4X_MAIL_TYPE) {
printf("sorry, movemail not supported yet.\n");
rv = newMOVEMAILMailPath->Exists(&exists);
if (NS_FAILED(rv)) return rv;
if (!exists) {