finish IDL-ifying these interfaces

Also stop caching the local mail directory in the pop3 sink and instead ask for it on demand from the nsIMsgIncomingServer
This commit is contained in:
alecf%netscape.com 1999-05-27 04:56:53 +00:00
parent 2a593d8922
commit d8a5753963
7 changed files with 156 additions and 74 deletions

View File

@ -20,8 +20,17 @@ topsrcdir = @top_srcdir@
VPATH = @srcdir@
srcdir = @srcdir@
MODULE=localmail
include $(DEPTH)/config/autoconf.mk
XPIDLSRCS = \
nsIPop3IncomingServer.idl \
nsIPop3Service.idl \
nsIMailboxService.idl \
nsIPop3Sink.idl \
$(NULL)
EXPORTS= \
nsIPop3Sink.h \
nsIPop3URL.h \

View File

@ -6,11 +6,7 @@
#define __gen_nsIPop3IncomingServer_h__
#include "nsISupports.h" /* interface nsISupports */
#include "nsID.h" /* interface nsID */
#ifdef XPIDL_JS_STUBS
#include "jsapi.h"
#endif
#include "nsrootidl.h" /* interface nsrootidl */
/* starting interface: nsIPop3IncomingServer */
@ -24,10 +20,6 @@ class nsIPop3IncomingServer : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPOP3INCOMINGSERVER_IID)
/* attribute string rootFolderPath; */
NS_IMETHOD GetRootFolderPath(char * *aRootFolderPath) = 0;
NS_IMETHOD SetRootFolderPath(char * aRootFolderPath) = 0;
/* attribute boolean leaveMessagesOnServer; */
NS_IMETHOD GetLeaveMessagesOnServer(PRBool *aLeaveMessagesOnServer) = 0;
NS_IMETHOD SetLeaveMessagesOnServer(PRBool aLeaveMessagesOnServer) = 0;
@ -35,11 +27,6 @@ class nsIPop3IncomingServer : public nsISupports {
/* attribute boolean deleteMailLeftOnServer; */
NS_IMETHOD GetDeleteMailLeftOnServer(PRBool *aDeleteMailLeftOnServer) = 0;
NS_IMETHOD SetDeleteMailLeftOnServer(PRBool aDeleteMailLeftOnServer) = 0;
#ifdef XPIDL_JS_STUBS
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIPop3IncomingServer *priv);
#endif
};
#endif /* __gen_nsIPop3IncomingServer_h__ */

View File

@ -21,7 +21,6 @@
[object, uuid(758a8970-e628-11d2-b7fc-00805f05ffa5)]
interface nsIPop3IncomingServer : nsISupports {
attribute string rootFolderPath;
attribute boolean leaveMessagesOnServer;
attribute boolean deleteMailLeftOnServer;

View File

@ -1,59 +1,68 @@
/* -*- 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) 1998 Netscape Communications Corporation. All Rights
* Reserved.
/*
* DO NOT EDIT. THIS FILE IS GENERATED FROM nsIPop3Sink.idl
*/
#ifndef nsIPop3Sink_h__
#define nsIPop3Sink_h__
#ifndef __gen_nsIPop3Sink_h__
#define __gen_nsIPop3Sink_h__
#include "nsISupports.h"
#include "nsIPop3IncomingServer.h"
#include "nsISupports.h" /* interface nsISupports */
#include "nsIPop3IncomingServer.h" /* interface nsIPop3IncomingServer */
#include "nsrootidl.h" /* interface nsrootidl */
class nsIURL; /* forward decl */
/* starting interface nsIPop3Sink */
/* starting interface: nsIPop3Sink */
/* {EC54D490-BB00-11D2-AB5E-00805F8AC968} */
#define NS_IPOP3SINK_IID_STR "EC54D490-BB00-11D2-AB5E-00805F8AC968"
#define NS_IPOP3SINK_IID \
{0xEC54D490, 0xBB00, 0x11D2, \
{0xAB, 0x5E, 0x00, 0x80, 0x5F, 0x8A, 0xC9, 0x68}}
{ 0xAB, 0x5E, 0x00, 0x80, 0x5F, 0x8A, 0xC9, 0x68 }}
class nsIPop3Sink : public nsISupports
{
public:
static const nsIID& GetIID() {
static nsIID iid = NS_IPOP3SINK_IID;
return iid;
}
class nsIPop3Sink : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPOP3SINK_IID)
NS_IMETHOD SetUserAuthenticated(PRBool authed) = 0;
NS_IMETHOD SetMailAccountURL(const char* urlString) = 0;
NS_IMETHOD BeginMailDelivery(PRBool *aBool) = 0;
NS_IMETHOD EndMailDelivery() = 0;
NS_IMETHOD AbortMailDelivery() = 0;
NS_IMETHOD IncorporateBegin(const char* uidlString, nsIURL* aURL,
PRUint32 flags, void** closure) = 0;
NS_IMETHOD IncorporateWrite(void* closure, const char* block,
PRInt32 length) = 0;
NS_IMETHOD IncorporateComplete(void* closure) = 0;
NS_IMETHOD IncorporateAbort(void* closure, PRInt32 status) = 0;
NS_IMETHOD BiffGetNewMail() = 0;
NS_IMETHOD SetBiffStateAndUpdateFE(PRUint32 aBiffState) = 0;
NS_IMETHOD SetSenderAuthedFlag(void* closure, PRBool authed) = 0;
NS_IMETHOD SetPopServer(nsIPop3IncomingServer *server) = 0;
NS_IMETHOD GetPopServer(nsIPop3IncomingServer* *server) = 0;
/* attribute boolean userAuthenticated; */
NS_IMETHOD GetUserAuthenticated(PRBool *aUserAuthenticated) = 0;
NS_IMETHOD SetUserAuthenticated(PRBool aUserAuthenticated) = 0;
/* attribute string mailAccountURL; */
NS_IMETHOD GetMailAccountURL(char * *aMailAccountURL) = 0;
NS_IMETHOD SetMailAccountURL(char * aMailAccountURL) = 0;
/* boolean BeginMailDelivery (); */
NS_IMETHOD BeginMailDelivery(PRBool *_retval) = 0;
/* void EndMailDelivery (); */
NS_IMETHOD EndMailDelivery() = 0;
/* void AbortMailDelivery (); */
NS_IMETHOD AbortMailDelivery() = 0;
/* voidStar IncorporateBegin (in string uidlString, in nsIURL aURL, in unsigned long flags); */
NS_IMETHOD IncorporateBegin(const char *uidlString, nsIURL *aURL, PRUint32 flags, void * *_retval) = 0;
/* void IncorporateWrite (in voidStar closure, in string block, in long length); */
NS_IMETHOD IncorporateWrite(void * closure, const char *block, PRInt32 length) = 0;
/* void IncorporateComplete (in voidStar closure); */
NS_IMETHOD IncorporateComplete(void * closure) = 0;
/* void IncorporateAbort (in voidStar closure, in long status); */
NS_IMETHOD IncorporateAbort(void * closure, PRInt32 status) = 0;
/* void BiffGetNewMail (); */
NS_IMETHOD BiffGetNewMail() = 0;
/* void SetBiffStateAndUpdateFE (in unsigned long biffState); */
NS_IMETHOD SetBiffStateAndUpdateFE(PRUint32 biffState) = 0;
/* void SetSenderAuthedFlag (in voidStar closure, in boolean authed); */
NS_IMETHOD SetSenderAuthedFlag(void * closure, PRBool authed) = 0;
/* attribute nsIPop3IncomingServer popServer; */
NS_IMETHOD GetPopServer(nsIPop3IncomingServer * *aPopServer) = 0;
NS_IMETHOD SetPopServer(nsIPop3IncomingServer * aPopServer) = 0;
};
#endif /* nsIPop3Sink_h__ */
#endif /* __gen_nsIPop3Sink_h__ */

View File

@ -0,0 +1,52 @@
/* -*- 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 "nsISupports.idl"
#include "nsIPop3IncomingServer.idl"
interface nsIURL;
[scriptable, uuid(EC54D490-BB00-11D2-AB5E-00805F8AC968)]
interface nsIPop3Sink : nsISupports {
attribute boolean userAuthenticated;
attribute string mailAccountURL;
boolean BeginMailDelivery();
void EndMailDelivery();
void AbortMailDelivery();
/* returns a closure ? */
voidStar IncorporateBegin(in string uidlString, in nsIURL aURL,
in unsigned long flags);
void IncorporateWrite(in voidStar closure, in string block,
in long length);
void IncorporateComplete(in voidStar closure);
void IncorporateAbort(in voidStar closure, in long status);
void BiffGetNewMail();
void SetBiffStateAndUpdateFE(in unsigned long biffState);
void SetSenderAuthedFlag(in voidStar closure, in boolean authed);
attribute nsIPop3IncomingServer popServer;
};

View File

@ -38,7 +38,6 @@ nsPop3Sink::nsPop3Sink()
m_senderAuthed = PR_FALSE;
m_outputBuffer = nsnull;
m_outputBufferSize = 0;
m_mailDirectory = 0;
m_newMailParser = NULL;
#ifdef DEBUG
m_fileCounter = 0;
@ -51,7 +50,6 @@ nsPop3Sink::~nsPop3Sink()
{
PR_FREEIF(m_accountUrl);
PR_FREEIF(m_outputBuffer);
PR_FREEIF(m_mailDirectory);
NS_IF_RELEASE(m_popServer);
if (m_newMailParser)
delete m_newMailParser;
@ -70,6 +68,16 @@ nsPop3Sink::SetUserAuthenticated(PRBool authed)
return NS_OK;
}
nsresult
nsPop3Sink::GetUserAuthenticated(PRBool* authed)
{
NS_ASSERTION(authed, "null getter in GetUserAuthenticated");
if (!authed) return NS_ERROR_NULL_POINTER;
*authed=m_authed;
return NS_OK;
}
nsresult
nsPop3Sink::SetSenderAuthedFlag(void* closure, PRBool authed)
{
@ -85,7 +93,7 @@ nsPop3Sink::SetSenderAuthedFlag(void* closure, PRBool authed)
}
nsresult
nsPop3Sink::SetMailAccountURL(const char* urlString)
nsPop3Sink::SetMailAccountURL(char* urlString)
{
if (urlString)
{
@ -105,6 +113,16 @@ nsPop3Sink::SetMailAccountURL(const char* urlString)
return NS_OK;
}
nsresult
nsPop3Sink::GetMailAccountURL(char* *urlString)
{
NS_ASSERTION(urlString, "null getter in getMailAccountURL");
if (!urlString) return NS_ERROR_NULL_POINTER;
*urlString = nsCRT::strdup(m_accountUrl);
return NS_OK;
}
nsresult
nsPop3Sink::BeginMailDelivery(PRBool* aBool)
{
@ -112,7 +130,17 @@ nsPop3Sink::BeginMailDelivery(PRBool* aBool)
m_fileCounter++;
#endif
nsFileSpec fileSpec(m_mailDirectory);
nsresult rv;
nsCOMPtr<nsIMsgIncomingServer> server = do_QueryInterface(m_popServer);
if (!server) return NS_ERROR_UNEXPECTED;
char *mailDirectory;
rv = server->GetLocalPath(&mailDirectory);
if (NS_FAILED(rv)) return rv;
nsFileSpec fileSpec(mailDirectory);
PL_strfree(mailDirectory);
fileSpec += "Inbox";
m_outFileStream = new nsIOFileStream(fileSpec,
PR_WRONLY | PR_CREATE_FILE);
@ -125,10 +153,11 @@ nsPop3Sink::BeginMailDelivery(PRBool* aBool)
if (m_newMailParser == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr <nsIFolder> serverFolder;
nsresult res = GetServerFolder(getter_AddRefs(serverFolder));
nsCOMPtr <nsIFolder> serverFolder;
rv = GetServerFolder(getter_AddRefs(serverFolder));
if (NS_FAILED(rv)) return rv;
nsresult rv = m_newMailParser->Init(serverFolder, fileSpec, m_outFileStream);
rv = m_newMailParser->Init(serverFolder, fileSpec, m_outFileStream);
if (NS_FAILED(rv)) return rv;
#ifdef DEBUG
@ -187,7 +216,6 @@ nsPop3Sink::IncorporateBegin(const char* uidlString,
#endif
if (closure)
*closure = (void*) this;
PR_ASSERT(m_mailDirectory);
char *dummyEnvelope = GetDummyEnvelope();
@ -205,9 +233,6 @@ nsPop3Sink::SetPopServer(nsIPop3IncomingServer *server)
m_popServer=server;
NS_ADDREF(m_popServer);
PR_FREEIF(m_mailDirectory);
m_popServer->GetRootFolderPath(&m_mailDirectory);
return NS_OK;
}

View File

@ -40,7 +40,9 @@ public:
NS_DECL_ISUPPORTS
NS_IMETHOD SetUserAuthenticated(PRBool authed);
NS_IMETHOD SetMailAccountURL(const char* urlString);
NS_IMETHOD GetUserAuthenticated(PRBool *authed);
NS_IMETHOD SetMailAccountURL(char* urlString);
NS_IMETHOD GetMailAccountURL(char* *urlString);
NS_IMETHOD BeginMailDelivery(PRBool *aBool);
NS_IMETHOD EndMailDelivery();
NS_IMETHOD AbortMailDelivery();
@ -70,7 +72,6 @@ protected:
PRBool m_senderAuthed;
char* m_outputBuffer;
PRInt32 m_outputBufferSize;
char* m_mailDirectory;
nsIPop3IncomingServer *m_popServer;
nsParseNewMailState *m_newMailParser;
#ifdef DEBUG