This commit is contained in:
rhp%netscape.com 1999-06-11 23:42:45 +00:00
Родитель 7994bc71ac
Коммит c41ee84f6a
15 изменённых файлов: 291 добавлений и 148 удалений

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

@ -44,7 +44,7 @@ Rights Reserved.
<!ENTITY saveAsFileCmd.label ".File">
<!ENTITY saveAsTemplateCmd.label ".Template">
<!ENTITY getNewMsgCmd.label "Get New Messages">
<!ENTITY sendUnsentCmd.label ".Send Unsent Messages">
<!ENTITY sendUnsentCmd.label "Send Unsent Messages">
<!ENTITY updateMsgCountCmd.label ".Update Message Count">
<!ENTITY subscribeCmd.label ".Subscribe">
<!ENTITY renameFolderCmd.label ".Rename Folder...">

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

@ -853,6 +853,17 @@ nsMessenger::GetTransactionManager(nsITransactionManager* *aTxnMgr)
return NS_OK;
}
nsresult
SendUnsentMessagesCallback(nsresult aExitCode, PRUint32 totalSentCount,
PRUint32 totalSentSuccessfully, void *tagData)
{
#ifdef NS_DEBUG
printf("SendUnsentMessagesCallback: Tried to send %d messages. %d successful.\n",
totalSentCount, totalSentSuccessfully);
#endif
return NS_OK;
}
NS_IMETHODIMP
nsMessenger::SendUnsentMessages()
{
@ -863,10 +874,7 @@ nsMessenger::SendUnsentMessages()
if (NS_SUCCEEDED(rv) && pMsgSendLater)
{
printf("We succesfully obtained a nsIMsgSendLater interface....\n");
pMsgSendLater->SendUnsentMessages(nsnull);
pMsgSendLater->SendUnsentMessages(nsnull, SendUnsentMessagesCallback, nsnull);
}
return NS_OK;
}

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

@ -27,7 +27,6 @@ XPIDLSRCS = \
nsIMsgComposeService.idl \
nsIMsgCompose.idl \
nsIMsgCompFields.idl \
nsIMsgSendLater.idl \
$(NULL)
EXPORTS = \
@ -41,6 +40,7 @@ EXPORTS = \
nsISmtpService.h \
MsgCompGlue.h \
nsMsgComposeBE.h \
nsIMsgSendLater.h \
$(NULL)
include $(topsrcdir)/config/config.mk

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

@ -22,7 +22,6 @@ XPIDLSRCS = \
.\nsIMsgComposeService.idl \
.\nsIMsgCompose.idl \
.\nsIMsgCompFields.idl \
.\nsIMsgSendLater.idl \
$(NULL)
################################################################################
@ -38,6 +37,7 @@ EXPORTS = \
nsISmtpService.h \
MsgCompGlue.h \
nsMsgComposeBE.h \
nsIMsgSendLater.h \
$(NULL)
include <$(DEPTH)\config\rules.mak>

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

@ -39,6 +39,16 @@ class nsIMsgSend : public nsISupports {
nsMsgSendCompletionCallback completionCallback,
void *tagData) = 0;
NS_IMETHOD SendMessageFile(
nsIMsgCompFields *fields,
nsFileSpec *sendFileSpec,
PRBool deleteSendFileOnCompletion,
PRBool digest_p,
nsMsgDeliverMode mode,
nsMsgSendCompletionCallback completionCallback,
void *tagData) = 0;
#ifdef XPIDL_JS_STUBS
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIMsgSend *priv);

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

@ -39,5 +39,6 @@ in const struct nsMsgAttachedFile *preloaded_attachments,
in void *relatedPart nsMsgSendPart )
*******/
void SendMessageFile();
};

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

@ -19,9 +19,15 @@
#include "nsISupports.idl"
#include "nsIMsgIdentity.idl"
%{ C++
#include "nsMsgComposeBE.h"
%}
[scriptable, uuid(E15C83E8-1CF4-11d3-8EF0-00A024A7D144)]
interface nsIMsgSendLater : nsISupports {
void SendUnsentMessages(in nsIMsgIdentity identity);
void SendUnsentMessages(in nsIMsgIdentity identity,
in nsMsgSendUnsentMessagesCallback msgCallback,
in void *tagData);
};

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

@ -20,6 +20,7 @@
#define _nsMsgComposeBE_H_
#include "rosetta.h"
#include "nsFileSpec.h"
//
// Composition back end declarations...
@ -28,13 +29,12 @@
//
// Callback declarations for message delivery
//
// For completion of send operations...
typedef nsresult (*nsMsgSendCompletionCallback) (nsresult aExitCode, void *tagData);
// For completion of message creation operations...
typedef nsresult (*nsMsgCreateCompletionCallback) (nsresult aExitCode, nsFileSpec *msgFile, void *tagData);
// For completion of send/message creation operations...
typedef nsresult (*nsMsgSendCompletionCallback) (nsresult aExitCode, void *tagData, nsFileSpec *returnFileSpec);
// For completion of sending unsent messages operations...
typedef nsresult (*nsMsgSendUnsentMessagesCallback) (nsresult aExitCode, PRUint32 totalSentCount,
PRUint32 totalSentSuccessfully, void *tagData);
// Message delivery modes
typedef enum

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

@ -57,6 +57,8 @@ GetTheTempDirectoryOnTheSystem(void)
GetWindowsDirectory(retPath, TPATH_LEN);
#endif
// RICHIE - should do something better here!
#ifdef XP_UNIX
PL_strncpy(retPath, "/tmp/", TPATH_LEN);
#endif

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

@ -1125,14 +1125,14 @@ nsMsgComposeAndSend::GatherMimeAttachments ()
if (m_dont_deliver_p && mSendCompleteCallback)
{
mSendCompleteCallback (NS_OK, m_fe_data);
//
// Need to ditch the file spec here so that we don't delete the
// file, since in this case, the caller wants the file
//
mReturnFileSpec = mTempFileSpec;
mTempFileSpec = nsnull;
mSendCompleteCallback (NS_OK, m_fe_data, mReturnFileSpec);
mSendCompleteCallback = 0;
Clear();
}
@ -1505,6 +1505,7 @@ nsMsgComposeAndSend::InitCompositionFields(nsMsgCompFields *fields)
nsresult
nsMsgComposeAndSend::Init(
nsMsgCompFields *fields,
nsFileSpec *sendFileSpec,
PRBool digest_p,
PRBool dont_deliver_p,
nsMsgDeliverMode mode,
@ -1540,9 +1541,21 @@ nsMsgComposeAndSend::Init(
if (NS_FAILED(rv))
return rv;
//
// At this point, if we are only creating this object to do
// send operations on externally created RFC822 disk files,
// make sure we have setup the appropriate nsFileSpec and
// move on with life.
//
//
// First check to see if we are doing a send operation on an external file
// or creating the file itself.
//
if (sendFileSpec)
{
mTempFileSpec = sendFileSpec;
return NS_OK;
}
// Setup related part information
m_related_part = relatedPart;
@ -1616,7 +1629,7 @@ NewsDeliveryCallback(nsIURL *aUrl, nsresult aExitCode, void *tagData)
{
nsMsgComposeAndSend *ptr = (nsMsgComposeAndSend *) tagData;
ptr->DeliverAsNewsExit(aUrl, aExitCode);
NS_RELEASE(ptr);
NS_RELEASE(ptr);
}
return aExitCode;
@ -1719,8 +1732,7 @@ nsMsgComposeAndSend::DeliverFileAsNews ()
if (NS_SUCCEEDED(rv) && nntpService)
{
NS_ADDREF(this);
NS_ADDREF(this);
nsMsgDeliveryListener *sendListener = new nsMsgDeliveryListener(NewsDeliveryCallback, nsNewsDelivery, this);
if (!sendListener)
{
@ -1803,7 +1815,7 @@ nsMsgComposeAndSend::DeliverAsNewsExit(nsIURL *aUrl, nsresult aExitCode)
// No real reason to bother the user at this point.
//
if (mSendCompleteCallback)
mSendCompleteCallback (aExitCode, m_fe_data);
mSendCompleteCallback (aExitCode, m_fe_data, nsnull);
mSendCompleteCallback = nsnull;
return;
@ -2035,7 +2047,7 @@ JFD */
op->unrefer();
/* The message has now been queued successfully. */
if (mSendCompleteCallback)
mSendCompleteCallback (NS_OK, m_fe_data);
mSendCompleteCallback (NS_OK, m_fe_data, nsnull);
mSendCompleteCallback = 0;
// Clear() clears the Fcc path
@ -2525,7 +2537,7 @@ nsMsgComposeAndSend::PostListImapMailboxFolder ( URL_Struct *url,
// treated as successful close down the compose window
/* The message has now been queued successfully. */
if (state->mSendCompleteCallback)
state->mSendCompleteCallback(NS_OK, state->m_fe_data);
state->mSendCompleteCallback(NS_OK, state->m_fe_data, nsnull);
state->mSendCompleteCallback = 0;
// Clear() clears the Fcc path
@ -2742,7 +2754,7 @@ nsMsgComposeAndSend::PostSendToImapMagicFolder ( URL_Struct *url,
// treated as successful close down the compose window
/* The message has now been queued successfully. */
if (state->mSendCompleteCallback)
state->mSendCompleteCallback (NS_OK, state->m_fe_data);
state->mSendCompleteCallback (NS_OK, state->m_fe_data, nsnull);
state->mSendCompleteCallback = 0;
// Clear() clears the Fcc path
@ -2839,7 +2851,7 @@ nsMsgComposeAndSend::PostSendToImapMagicFolder ( URL_Struct *url,
}
/* The message has now been queued successfully. */
if (state->mSendCompleteCallback)
state->mSendCompleteCallback (NS_OK, state->m_fe_data);
state->mSendCompleteCallback (NS_OK, state->m_fe_data, nsnull);
state->mSendCompleteCallback = 0;
// Clear() clears the Fcc path
@ -2922,7 +2934,7 @@ nsMsgComposeAndSend::SendToMagicFolder ( PRUint32 flag )
/* The message has now been queued successfully. */
if (mSendCompleteCallback)
mSendCompleteCallback (NS_OK, m_fe_data);
mSendCompleteCallback (NS_OK, m_fe_data, nsnull);
mSendCompleteCallback = 0;
Clear();
@ -3005,7 +3017,7 @@ nsMsgComposeAndSend::Fail(nsresult failure_code, char *error_msg)
if (mSendCompleteCallback)
{
mSendCompleteCallback (failure_code, m_fe_data);
mSendCompleteCallback (failure_code, m_fe_data, nsnull);
}
else if (m_attachments_done_callback)
{
@ -3075,7 +3087,7 @@ nsMsgComposeAndSend::DeliverAsMailExit(nsIURL *aUrl, nsresult aExitCode)
// No real reason to bother the user at this point.
//
if (mSendCompleteCallback)
mSendCompleteCallback (aExitCode, m_fe_data);
mSendCompleteCallback (aExitCode, m_fe_data, nsnull);
mSendCompleteCallback = nsnull;
return;
@ -3199,9 +3211,11 @@ nsMsgComposeAndSend::Clear()
if (mTempFileSpec)
{
mTempFileSpec->Delete(PR_FALSE);
delete mTempFileSpec;
mTempFileSpec = nsnull;
if (mReturnFileSpec == nsnull)
{
mTempFileSpec->Delete(PR_FALSE);
delete mTempFileSpec;
}
}
HJ82388
@ -3351,15 +3365,14 @@ nsMsgComposeAndSend::CreateAndSendMessage(
{
nsresult rv;
// RICHIE-SHERRY
//extern void DoItDude(void);
//DoItDude();
//return NS_OK;
// Make sure the completion callback is setup first...
mSendCompleteCallback = completionCallback;
if (!attachment1_body || !*attachment1_body)
attachment1_type = attachment1_body = 0;
rv = Init((nsMsgCompFields *)fields,
rv = Init((nsMsgCompFields *)fields, nsnull,
digest_p, dont_deliver_p, mode,
attachment1_type, attachment1_body,
attachment1_body_length,
@ -3368,8 +3381,47 @@ nsMsgComposeAndSend::CreateAndSendMessage(
tagData);
if (NS_SUCCEEDED(rv))
{
mSendCompleteCallback = completionCallback;
return NS_OK;
else
return rv;
}
nsresult
nsMsgComposeAndSend::SendMessageFile(
nsIMsgCompFields *fields,
nsFileSpec *sendFileSpec,
PRBool deleteSendFileOnCompletion,
PRBool digest_p,
nsMsgDeliverMode mode,
nsMsgSendCompletionCallback completionCallback,
void *tagData)
{
nsresult rv;
//
// First check to see if the external file we are sending is a valid file.
//
if (!sendFileSpec)
return NS_ERROR_FAILURE;
if (!sendFileSpec->Exists())
return NS_ERROR_FAILURE;
// Make sure the completion callback is setup first...
mSendCompleteCallback = completionCallback;
// Should we delete the temp file when done?
if (!deleteSendFileOnCompletion)
mReturnFileSpec = sendFileSpec;
rv = Init((nsMsgCompFields *)fields, sendFileSpec,
digest_p, PR_FALSE, mode,
nsnull, nsnull, nsnull,
nsnull, nsnull, nsnull,
tagData);
if (NS_SUCCEEDED(rv))
{
DeliverMessage();
return NS_OK;
}
else
@ -3645,7 +3697,6 @@ nsMsgComposeAndSend::MimeDoFCC (
goto FAIL;
}
/* Write out the X-Mozilla-News-Host header.
This is done only when writing to the queue file, not the FCC file.
We need this to complement the "Newsgroups" header for the case of

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

@ -317,6 +317,7 @@ public:
//
nsresult Init(
nsMsgCompFields *fields,
nsFileSpec *sendFileSpec,
PRBool digest_p,
PRBool dont_deliver_p,
nsMsgDeliverMode mode,
@ -364,6 +365,15 @@ public:
nsMsgSendCompletionCallback completionCallback,
void *tagData);
NS_IMETHOD SendMessageFile(
nsIMsgCompFields *fields,
nsFileSpec *sendFileSpec,
PRBool deleteSendFileOnCompletion,
PRBool digest_p,
nsMsgDeliverMode mode,
nsMsgSendCompletionCallback completionCallback,
void *tagData);
//
// All vars necessary for this implementation
//

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

@ -31,16 +31,21 @@
#include "nsIMsgMailSession.h"
#include "nsIMsgAccountManager.h"
#include "nsMsgBaseCID.h"
#include "nsMsgCompCID.h"
#include "nsMsgCompUtils.h"
#include "nsMsgUtils.h"
#include "nsMsgFolderFlags.h"
#include "nsIMessage.h"
#include "nsIRDFResource.h"
#include "nsISupportsArray.h"
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
static NS_DEFINE_CID(kCMsgMailSessionCID, NS_MSGMAILSESSION_CID);
static NS_DEFINE_CID(kSmtpServiceCID, NS_SMTPSERVICE_CID);
static NS_DEFINE_IID(kIMsgSendLater, NS_IMSGSENDLATER_IID);
static NS_DEFINE_CID(kMsgCompFieldsCID, NS_MSGCOMPFIELDS_CID);
static NS_DEFINE_CID(kMsgSendCID, NS_MSGSEND_CID);
static NS_DEFINE_CID(kISupportsArrayCID, NS_SUPPORTSARRAY_CID);
//
// This function will be used by the factory to generate the
@ -67,18 +72,26 @@ NS_IMPL_ISUPPORTS(nsMsgSendLater, nsIMsgSendLater::GetIID())
nsMsgSendLater::nsMsgSendLater()
{
mIdentity = nsnull;
mTempIFileSpec = nsnull;
mTempFileSpec = nsnull;
mEnumerator = nsnull;
mFirstTime = PR_TRUE;
mTotalSentSuccessfully = 0;
mTotalSendCount = 0;
mCompleteCallback = nsnull;
mTagData = nsnull;
mMessageFolder = nsnull;
mMessage = nsnull;
NS_INIT_REFCNT();
}
nsMsgSendLater::~nsMsgSendLater()
{
NS_RELEASE(mEnumerator);
if (mTempFileSpec)
delete mTempFileSpec;
if (mEnumerator)
NS_RELEASE(mEnumerator);
if (mTempIFileSpec)
NS_RELEASE(mTempIFileSpec);
}
nsresult
@ -95,6 +108,12 @@ SaveMessageCompleteCallback(nsIURL *aUrl, nsresult aExitCode, void *tagData)
printf("nsMsgSendLater: Success on the message save...\n");
#endif
rv = ptr->CompleteMailFileSend();
// If the send operation failed..try the next one...
if (NS_FAILED(rv))
rv = ptr->StartNextMailFileSend();
NS_RELEASE(ptr);
}
}
@ -102,9 +121,9 @@ SaveMessageCompleteCallback(nsIURL *aUrl, nsresult aExitCode, void *tagData)
}
nsresult
SendMessageCompleteCallback(nsIURL *aUrl, nsresult aExitCode, void *tagData)
SendMessageCompleteCallback(nsresult aExitCode, void *tagData, nsFileSpec *returnFileSpec)
{
nsresult rv = NS_OK;
nsresult rv = NS_OK;
if (tagData)
{
@ -115,7 +134,21 @@ SendMessageCompleteCallback(nsIURL *aUrl, nsresult aExitCode, void *tagData)
printf("nsMsgSendLater: Success on the message send operation!\n");
#endif
PRBool deleteMsgs = PR_FALSE;
//
// Now delete the message from the outbox folder.
//
NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &rv);
if (NS_SUCCEEDED(rv) && prefs)
prefs->GetBoolPref("mail.really_delete_unsent_messages", &deleteMsgs);
if (deleteMsgs)
ptr->DeleteCurrentMessage();
++(ptr->mTotalSentSuccessfully);
rv = ptr->StartNextMailFileSend();
NS_RELEASE(ptr);
}
}
@ -125,34 +158,55 @@ SendMessageCompleteCallback(nsIURL *aUrl, nsresult aExitCode, void *tagData)
nsresult
nsMsgSendLater::CompleteMailFileSend()
{
nsresult rv;
nsresult rv;
nsString recips;
nsString ccList;
PRBool created;
nsCOMPtr<nsIMsgCompFields> compFields = nsnull;
nsCOMPtr<nsIMsgSend> pMsgSend = nsnull;
NS_WITH_SERVICE(nsISmtpService, smtpService, kSmtpServiceCID, &rv);
if (NS_FAILED(rv) || !smtpService)
// If for some reason the tmp file didn't get created, we've failed here
mTempIFileSpec->exists(&created);
if (!created)
return NS_ERROR_FAILURE;
char *aUnixStyleFilePath;
nsString recips;
mMessage->GetRecipients(recips);
printf("SEND THIS : [%s]\n", recips.GetBuffer());
mMessage->GetRecipients(recips);
char *buf = recips.ToNewCString();
mTempFileSpec->GetUnixStyleFilePath(&aUnixStyleFilePath);
if (!aUnixStyleFilePath)
// Get the recipients...
if (NS_FAILED(mMessage->GetRecipients(recips)))
return NS_ERROR_FAILURE;
else
mMessage->GetCCList(ccList);
nsFilePath filePath (aUnixStyleFilePath);
nsMsgDeliveryListener *sendListener = new nsMsgDeliveryListener(SendMessageCompleteCallback,
nsMailDelivery, this);
if (!sendListener)
// Get the composition fields interface
nsresult res = nsComponentManager::CreateInstance(kMsgCompFieldsCID, NULL, nsIMsgCompFields::GetIID(),
(void **) getter_AddRefs(compFields));
if (NS_FAILED(res) || !compFields)
{
return NS_ERROR_FAILURE;
}
rv = smtpService->SendMailMessage(filePath, buf, nsnull, nsnull);
PR_FREEIF(buf);
// Get the message send interface
rv = nsComponentManager::CreateInstance(kMsgSendCID, NULL, nsIMsgSend::GetIID(),
(void **) getter_AddRefs(pMsgSend));
if (NS_FAILED(res) || !pMsgSend)
{
return NS_ERROR_FAILURE;
}
char *recipients = recips.ToNewCString();
char *cc = ccList.ToNewCString();
compFields->SetTo(recipients, NULL);
compFields->SetCc(cc, NULL);
NS_ADDREF(this);
PR_FREEIF(recipients);
PR_FREEIF(cc);
rv = pMsgSend->SendMessageFile(compFields, // nsIMsgCompFields *fields,
mTempFileSpec, // nsFileSpec *sendFileSpec,
PR_TRUE, // PRBool deleteSendFileOnCompletion,
PR_FALSE, // PRBool digest_p,
nsMsgDeliverNow, // nsMsgDeliverMode mode,
SendMessageCompleteCallback, // nsMsgSendCompletionCallback completionCallback,
this); // void *tagData);
if (NS_FAILED(rv))
return NS_ERROR_FAILURE;
@ -177,12 +231,15 @@ nsMsgSendLater::StartNextMailFileSend()
}
else
mEnumerator->Next();
if (mEnumerator->IsDone() == NS_OK)
{
// Call any caller based callbacks and then exit cleanly
#ifdef NS_DEBUG
printf("nsMsgSendLater: Finished all \"Send Later\" operations successfully!\n");
#endif
if (mCompleteCallback)
mCompleteCallback(NS_OK, mTotalSendCount, mTotalSentSuccessfully, mTagData);
return NS_OK;
}
@ -213,16 +270,15 @@ nsMsgSendLater::StartNextMailFileSend()
nsString subject;
mMessage->GetSubject(subject);
tString = subject.ToNewCString();
printf("Fun subject %s\n", tString);
printf("Sending message: [%s]\n", tString);
PR_FREEIF(tString);
nsFileSpec *tSpec = nsMsgCreateTempFileSpec("nsmail.tmp");
if (!tSpec)
mTempFileSpec = nsMsgCreateTempFileSpec("nsmail.tmp");
if (!mTempFileSpec)
return NS_ERROR_FAILURE;
// NS_NewFileSpecWithSpec(*tSpec, &mTempFileSpec);
delete tSpec;
if (!mTempFileSpec)
NS_NewFileSpecWithSpec(*mTempFileSpec, &mTempIFileSpec);
if (!mTempIFileSpec)
return NS_ERROR_FAILURE;
nsIMsgMessageService * messageService = nsnull;
@ -230,6 +286,9 @@ nsMsgSendLater::StartNextMailFileSend()
if (NS_FAILED(rv) && !messageService)
return NS_ERROR_FAILURE;
++mTotalSendCount;
NS_ADDREF(this);
nsMsgDeliveryListener *sendListener = new nsMsgDeliveryListener(SaveMessageCompleteCallback,
nsFileSaveDelivery, this);
if (!sendListener)
@ -238,7 +297,7 @@ nsMsgSendLater::StartNextMailFileSend()
return NS_ERROR_FAILURE;
}
rv = messageService->SaveMessageToDisk(aMessageURI, mTempFileSpec, PR_FALSE, sendListener, nsnull);
rv = messageService->SaveMessageToDisk(aMessageURI, mTempIFileSpec, PR_FALSE, sendListener, nsnull);
ReleaseMessageServiceFromURI(aMessageURI, messageService);
if (NS_FAILED(rv))
@ -295,14 +354,22 @@ nsMsgSendLater::GetUnsentMessagesFolder(nsIMsgIdentity *userIdentity)
}
nsresult
nsMsgSendLater::SendUnsentMessages(nsIMsgIdentity *identity)
nsMsgSendLater::SendUnsentMessages(nsIMsgIdentity *identity,
nsMsgSendUnsentMessagesCallback msgCallback,
void *tagData)
{
if (!identity)
// RICHIE - for now hack it mIdentity = identity;
nsIMsgIdentity *GetHackIdentity();
mIdentity = GetHackIdentity();
if (!mIdentity)
return NS_ERROR_FAILURE;
mIdentity = identity;
mCompleteCallback = msgCallback;
mTagData = tagData;
mMessageFolder = GetUnsentMessagesFolder(identity);
mMessageFolder = GetUnsentMessagesFolder(mIdentity);
if (!mMessageFolder)
return NS_ERROR_FAILURE;
@ -314,47 +381,8 @@ nsMsgSendLater::SendUnsentMessages(nsIMsgIdentity *identity)
return StartNextMailFileSend();
}
#include "nsIComponentManager.h"
#include "nsMsgCompCID.h"
#include "nsIMsgCompose.h"
#include "nsIMsgCompFields.h"
#include "nsIMsgSend.h"
#include "nsIPref.h"
#include "nsIServiceManager.h"
#include "nscore.h"
#include "nsIMsgMailSession.h"
#include "nsINetSupportDialogService.h"
#include "nsIAppShellService.h"
#include "nsAppShellCIDs.h"
#include "nsINetService.h"
#include "nsIComponentManager.h"
#include "nsString.h"
#include "nsISmtpService.h"
#include "nsISmtpUrl.h"
#include "nsIUrlListener.h"
#include "nsIEventQueueService.h"
#include "nsIEventQueue.h"
#include "nsIFileLocator.h"
#include "MsgCompGlue.h"
#include "nsCRT.h"
#include "prmem.h"
#include "nsIMimeURLUtils.h"
#include "nsMsgSendLater.h"
static NS_DEFINE_CID(kNetServiceCID, NS_NETSERVICE_CID);
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_CID(kFileLocatorCID, NS_FILELOCATOR_CID);
static NS_DEFINE_CID(kEventQueueCID, NS_EVENTQUEUE_CID);
static NS_DEFINE_CID(kMimeURLUtilsCID, NS_IMIME_URLUTILS_CID);
static NS_DEFINE_CID(kNetSupportDialogCID, NS_NETSUPPORTDIALOG_CID);
static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
static NS_DEFINE_IID(kIAppShellServiceIID, NS_IAPPSHELL_SERVICE_IID);
static NS_DEFINE_IID(kIMsgSendLaterIID, NS_IMSGSENDLATER_IID);
static NS_DEFINE_CID(kMsgSendLaterCID, NS_MSGSENDLATER_CID);
void DoItDude(void)
nsIMsgIdentity *
GetHackIdentity()
{
nsresult rv;
@ -362,37 +390,46 @@ nsresult rv;
if (NS_FAILED(rv))
{
printf("Failure on Mail Session Init!\n");
return ;
return nsnull;
}
nsCOMPtr<nsIMsgIdentity> identity = nsnull;
NS_WITH_SERVICE(nsIMsgMailSession, session, kCMsgMailSessionCID, &rv);
if (NS_FAILED(rv))
{
printf("Failure getting Mail Session!\n");
return ;
}
nsCOMPtr<nsIMsgIdentity> identity = nsnull;
nsCOMPtr<nsIMsgAccountManager> accountManager;
nsCOMPtr<nsIMsgAccountManager> accountManager;
rv = session->GetAccountManager(getter_AddRefs(accountManager));
rv = mailSession->GetAccountManager(getter_AddRefs(accountManager));
if (NS_FAILED(rv))
{
printf("Failure getting account Manager!\n");
return ;
return nsnull;
}
rv = session->GetCurrentIdentity(getter_AddRefs(identity));
rv = mailSession->GetCurrentIdentity(getter_AddRefs(identity));
if (NS_FAILED(rv))
{
printf("Failure getting Identity!\n");
return ;
return nsnull;
}
nsIMsgSendLater *pMsgSendLater;
rv = nsComponentManager::CreateInstance(kMsgSendLaterCID, NULL, kIMsgSendLaterIID, (void **) &pMsgSendLater);
if (rv == NS_OK && pMsgSendLater)
{
printf("We succesfully obtained a nsIMsgSendLater interface....\n");
pMsgSendLater->SendUnsentMessages(identity);
}
return identity;
}
nsresult
nsMsgSendLater::DeleteCurrentMessage()
{
nsCOMPtr<nsISupportsArray> msgArray;
// Get the composition fields interface
nsresult res = nsComponentManager::CreateInstance(kISupportsArrayCID, NULL, nsISupportsArray::GetIID(),
(void **) getter_AddRefs(msgArray));
if (NS_FAILED(res) || !msgArray)
{
return NS_ERROR_FAILURE;
}
msgArray->InsertElementAt(mMessage, 0);
res = mMessageFolder->DeleteMessages(msgArray, nsnull);
if (NS_FAILED(res))
return NS_ERROR_FAILURE;
return NS_OK;
}

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

@ -35,21 +35,32 @@ public:
NS_DECL_ISUPPORTS
// nsIMsgSendLater support
NS_IMETHOD SendUnsentMessages(nsIMsgIdentity *identity);
NS_IMETHOD SendUnsentMessages(nsIMsgIdentity *identity,
nsMsgSendUnsentMessagesCallback msgCallback,
void *tagData);
// Methods needed for implementing interface...
nsIMsgFolder *GetUnsentMessagesFolder(nsIMsgIdentity *userIdentity);
nsresult StartNextMailFileSend();
nsresult CompleteMailFileSend();
private:
nsresult DeleteCurrentMessage();
// counters
PRUint32 mTotalSentSuccessfully;
PRUint32 mTotalSendCount;
// Private Information
private:
nsIMsgIdentity *mIdentity;
nsCOMPtr<nsIMsgFolder> mMessageFolder;
nsCOMPtr<nsIMessage> mMessage;
nsIFileSpec *mTempFileSpec;
nsFileSpec *mTempFileSpec;
nsIFileSpec *mTempIFileSpec;
nsIEnumerator *mEnumerator;
PRBool mFirstTime;
nsMsgSendUnsentMessagesCallback mCompleteCallback;
void *mTagData;
};

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

@ -153,7 +153,7 @@ in RED!</font></font></b>\n\
</html>"};
nsresult
CallMe(nsresult aExitCode, void *tagData)
CallMe(nsresult aExitCode, void *tagData, nsFileSpec *fs)
{
char *buf = (char *)tagData;
@ -161,6 +161,13 @@ CallMe(nsresult aExitCode, void *tagData)
printf("Exit code = %d\n", aExitCode);
printf("What were the magic words => [%s]\n", buf);
PR_FREEIF(buf);
if (fs)
{
printf("Delivery NOT Requested: Just created an RFC822 file. URL=[%s]\n", fs->GetCString());
delete fs;
}
return NS_OK;
}
@ -278,11 +285,11 @@ int main(int argc, char *argv[])
char *tagBuf = (char *)PR_Malloc(256);
if (tagBuf)
PL_strcpy(tagBuf, "Do that voodo, you do, soooo welllll!\n");
PL_strcpy(tagBuf, "Do that voodo, that you do, soooo weeeelllll!");
pMsgSend->CreateAndSendMessage(pMsgCompFields,
PR_FALSE, // PRBool digest_p,
PR_FALSE, // PRBool dont_deliver_p,
PR_FALSE, // PRBool dont_deliver_p,
nsMsgDeliverNow, // nsMsgDeliverMode mode,
TEXT_HTML, //TEXT_PLAIN, // const char *attachment1_type,
pBody, // const char *attachment1_body,

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

@ -201,7 +201,7 @@ int main(int argc, char *argv[])
if (NS_SUCCEEDED(rv) && pMsgSendLater)
{
printf("We succesfully obtained a nsIMsgSendLater interface....\n");
pMsgSendLater->SendUnsentMessages(identity);
pMsgSendLater->SendUnsentMessages(identity, nsnull, nsnull);
}
#ifdef XP_PC