Add support for SMTPObserver, break out callbacks from SMTP Service

This commit is contained in:
spider%netscape.com 1998-10-30 18:32:32 +00:00
Родитель 347f6d6e7a
Коммит 8ade5d2f50
9 изменённых файлов: 555 добавлений и 356 удалений

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

@ -16,6 +16,7 @@ PRIVATE_EXPORTS = \
nsSMTPService.h \
nsMIMEService.h \
nsMessage.h \
nsSMTPServerCallback.h \
$(NULL)
MODULE = xpfc

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

@ -0,0 +1,47 @@
/* -*- 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.
*/
#ifndef nsSMTPServerCallback_h___
#define nsSMTPServerCallback_h___
#include "smtp.h"
#include "nsISMTPObserver.h"
void SMTPServerCallback_bdat( smtpSink_t *, int, const char * );
void SMTPServerCallback_connect( smtpSink_t *, int, const char * );
void SMTPServerCallback_data( smtpSink_t *, int, const char * );
void SMTPServerCallback_ehlo( smtpSink_t *, int, const char * );
void SMTPServerCallback_ehloComplete(smtpSink_t *);
void SMTPServerCallback_error( smtpSink_t *, int, const char * );
void SMTPServerCallback_expand( smtpSink_t *, int, const char * );
void SMTPServerCallback_expandComplete(smtpSink_t *);
void SMTPServerCallback_help( smtpSink_t *, int, const char * );
void SMTPServerCallback_helpComplete(smtpSink_t *);
void SMTPServerCallback_mailFrom( smtpSink_t *, int, const char * );
void SMTPServerCallback_noop( smtpSink_t *, int, const char * );
void SMTPServerCallback_quit( smtpSink_t *, int, const char * );
void SMTPServerCallback_rcptTo( smtpSink_t *, int, const char * );
void SMTPServerCallback_reset( smtpSink_t *, int, const char * );
void SMTPServerCallback_send( smtpSink_t *, int, const char * );
void SMTPServerCallback_sendCommand( smtpSink_t *, int, const char * );
void SMTPServerCallback_sendCommandComplete(smtpSink_t *);
void SMTPServerCallback_verify( smtpSink_t *, int, const char * );
void setSink(smtpSink_t * pSink,nsISMTPObserver * aObserver);
#endif /* nsSMTPServerCallback_h___ */

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

@ -30,8 +30,16 @@ public:
NS_IMETHOD Init() ;
NS_IMETHOD SendMail(nsString& aServer, nsString& aFrom, nsString& aTo, nsString& aSubject, nsString& aBody) ;
NS_IMETHOD SendMail(nsString& aServer, nsIMessage& aMessage) ;
NS_IMETHOD SendMail(nsString& aServer,
nsString& aFrom,
nsString& aTo,
nsString& aSubject,
nsString& aBody,
nsISMTPObserver * aObserver = nsnull);
NS_IMETHOD SendMail(nsString& aServer,
nsIMessage& aMessage,
nsISMTPObserver * aObserver = nsnull);
protected:

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

@ -13,6 +13,7 @@ DEPTH = ../../..
EXPORTS = \
nsISMTPService.h \
nsIMIMEService.h \
nsISMTPObserver.h \
nsIMessage.h \
$(NULL)

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

@ -0,0 +1,65 @@
/* -*- 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.
*/
#ifndef nsISMTPObserver_h___
#define nsISMTPObserver_h___
#include "nsISupports.h"
//fc251940-701f-11d2-8dbc-00805f8a7ab6
#define NS_ISMTP_OBSERVER_IID \
{ 0xfc251940, 0x701f, 0x11d2, \
{ 0x8d, 0xbc, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6 } }
typedef enum
{
nsSMTPMethod_bdat = 0,
nsSMTPMethod_connect = 1,
nsSMTPMethod_data = 2,
nsSMTPMethod_ehlo = 3,
nsSMTPMethod_ehloComplete = 4,
nsSMTPMethod_error = 5,
nsSMTPMethod_expand = 6,
nsSMTPMethod_expandComplete = 7,
nsSMTPMethod_help = 8,
nsSMTPMethod_helpComplete = 9,
nsSMTPMethod_mailFrom = 10,
nsSMTPMethod_noop = 11,
nsSMTPMethod_quit = 12,
nsSMTPMethod_rcpTo = 13,
nsSMTPMethod_reset = 14,
nsSMTPMethod_send = 15,
nsSMTPMethod_sendCommand = 16,
nsSMTPMethod_sendCommandComplete = 17,
nsSMTPMethod_verify = 18,
} nsSMTPMethod;
class nsISMTPObserver : public nsISupports
{
public:
NS_IMETHOD Init() = 0;
NS_IMETHOD ServerResponse(nsSMTPMethod aMethod,
PRInt32 aResponseCode,
nsString& aResponseString) = 0;
};
#endif /* nsISMTPObserver_h___ */

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

@ -22,6 +22,7 @@
#include "nsISupports.h"
#include "nsString.h"
#include "nsIMessage.h"
#include "nsISMTPObserver.h"
//b64f8b50-6f77-11d2-8dbc-00805f8a7ab6
#define NS_ISMTP_SERVICE_IID \
@ -35,8 +36,16 @@ public:
NS_IMETHOD Init() = 0;
NS_IMETHOD SendMail(nsString& aServer, nsString& aFrom, nsString& aTo, nsString& aSubject, nsString& aBody) = 0;
NS_IMETHOD SendMail(nsString& aServer, nsIMessage& aMessage) = 0;
NS_IMETHOD SendMail(nsString& aServer,
nsString& aFrom,
nsString& aTo,
nsString& aSubject,
nsString& aBody,
nsISMTPObserver * aObserver = nsnull) = 0;
NS_IMETHOD SendMail(nsString& aServer,
nsIMessage& aMessage,
nsISMTPObserver * aObserver = nsnull) = 0;
};

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

@ -21,6 +21,7 @@ CPPSRCS = \
nsSMTPService.cpp \
nsMIMEService.cpp \
nsMessage.cpp \
nsSMTPServerCallback.cpp \
$(NULL)
REQUIRES = xpcom raptor netlib msgsdk

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

@ -0,0 +1,225 @@
/* -*- 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.
*/
#include "smtp.h"
#include "nsStream.h"
#include "nsString.h"
#include "nsSMTPServerCallback.h"
void setSink(smtpSink_t * pSink, nsISMTPObserver * aObserver)
{
pSink->bdat = SMTPServerCallback_bdat;
pSink->connect = SMTPServerCallback_connect;
pSink->data = SMTPServerCallback_data;
pSink->ehlo = SMTPServerCallback_ehlo;
pSink->ehloComplete = SMTPServerCallback_ehloComplete;
pSink->error = SMTPServerCallback_error;
pSink->expand = SMTPServerCallback_expand;
pSink->expandComplete = SMTPServerCallback_expandComplete;
pSink->help = SMTPServerCallback_help;
pSink->helpComplete = SMTPServerCallback_helpComplete;
pSink->mailFrom = SMTPServerCallback_mailFrom;
pSink->noop = SMTPServerCallback_noop;
pSink->quit = SMTPServerCallback_quit;
pSink->rcptTo = SMTPServerCallback_rcptTo;
pSink->reset = SMTPServerCallback_reset;
pSink->send = SMTPServerCallback_send;
pSink->sendCommand = SMTPServerCallback_sendCommand;
pSink->sendCommandComplete = SMTPServerCallback_sendCommandComplete;
pSink->verify = SMTPServerCallback_verify;
pSink->pOpaqueData = (void*)aObserver;
}
// XXX: what to do for responses that have no code or message from server (ie completion callbacks)?
// Right now, we send '0' to the observer for the code and a cusom message for the response.
/*Notification for the response to the BDAT command.*/
void SMTPServerCallback_bdat( smtpSink_t * in_pSink, int in_responseCode, const char * in_responseMessage )
{
nsISMTPObserver * obs = (nsISMTPObserver *) in_pSink->pOpaqueData;
if (nsnull != obs)
obs->ServerResponse(nsSMTPMethod_bdat, in_responseCode, nsString(in_responseMessage));
}
/*Notification for the response to the connection to the server.*/
void SMTPServerCallback_connect( smtpSink_t * in_pSink, int in_responseCode, const char * in_responseMessage )
{
nsISMTPObserver * obs = (nsISMTPObserver *) in_pSink->pOpaqueData;
if (nsnull != obs)
obs->ServerResponse(nsSMTPMethod_connect, in_responseCode, nsString(in_responseMessage));
}
/*Notification for the response to the DATA command.*/
void SMTPServerCallback_data( smtpSink_t * in_pSink, int in_responseCode, const char * in_responseMessage )
{
nsISMTPObserver * obs = (nsISMTPObserver *) in_pSink->pOpaqueData;
if (nsnull != obs)
obs->ServerResponse(nsSMTPMethod_data, in_responseCode, nsString(in_responseMessage));
}
/*Notification for the response to the EHLO command.*/
void SMTPServerCallback_ehlo( smtpSink_t * in_pSink, int in_responseCode, const char * in_responseMessage )
{
nsISMTPObserver * obs = (nsISMTPObserver *) in_pSink->pOpaqueData;
if (nsnull != obs)
obs->ServerResponse(nsSMTPMethod_ehlo, in_responseCode, nsString(in_responseMessage));
}
/*Notification for the completion of the EHLO command.*/
void SMTPServerCallback_ehloComplete(smtpSink_t * in_pSink)
{
nsISMTPObserver * obs = (nsISMTPObserver *) in_pSink->pOpaqueData;
if (nsnull != obs)
obs->ServerResponse(nsSMTPMethod_ehloComplete, 0, nsString("EHLO complete\n"));
}
/*Notification for the response to a server error.*/
void SMTPServerCallback_error(smtpSink_t * in_pSink, int in_responseCode, const char * in_responseMessage )
{
nsISMTPObserver * obs = (nsISMTPObserver *) in_pSink->pOpaqueData;
if (nsnull != obs)
obs->ServerResponse(nsSMTPMethod_error, in_responseCode, nsString(in_responseMessage));
}
/*Notification for the response to the EXPN command.*/
void SMTPServerCallback_expand( smtpSink_t * in_pSink, int in_responseCode, const char * in_responseMessage )
{
nsISMTPObserver * obs = (nsISMTPObserver *) in_pSink->pOpaqueData;
if (nsnull != obs)
obs->ServerResponse(nsSMTPMethod_expand, in_responseCode, nsString(in_responseMessage));
}
/*Notification for the completion of the EXPN command.*/
void SMTPServerCallback_expandComplete(smtpSink_t * in_pSink)
{
nsISMTPObserver * obs = (nsISMTPObserver *) in_pSink->pOpaqueData;
if (nsnull != obs)
obs->ServerResponse(nsSMTPMethod_expandComplete, 0, nsString("EXPAND complete\n"));
}
/*Notification for the response to the HELP command.*/
void SMTPServerCallback_help( smtpSink_t * in_pSink, int in_responseCode, const char * in_responseMessage )
{
nsISMTPObserver * obs = (nsISMTPObserver *) in_pSink->pOpaqueData;
if (nsnull != obs)
obs->ServerResponse(nsSMTPMethod_help, in_responseCode, nsString(in_responseMessage));
}
/*Notification for the completion of the HELP command.*/
void SMTPServerCallback_helpComplete(smtpSink_t * in_pSink)
{
nsISMTPObserver * obs = (nsISMTPObserver *) in_pSink->pOpaqueData;
if (nsnull != obs)
obs->ServerResponse(nsSMTPMethod_helpComplete, 0, nsString("HElp Complete\n"));
}
/*Notification for the response to the MAIL FROM command.*/
void SMTPServerCallback_mailFrom( smtpSink_t * in_pSink, int in_responseCode, const char * in_responseMessage )
{
nsISMTPObserver * obs = (nsISMTPObserver *) in_pSink->pOpaqueData;
if (nsnull != obs)
obs->ServerResponse(nsSMTPMethod_mailFrom, in_responseCode, nsString(in_responseMessage));
}
/*Notification for the response to the NOOP command.*/
void SMTPServerCallback_noop( smtpSink_t * in_pSink, int in_responseCode, const char * in_responseMessage )
{
nsISMTPObserver * obs = (nsISMTPObserver *) in_pSink->pOpaqueData;
if (nsnull != obs)
obs->ServerResponse(nsSMTPMethod_noop, in_responseCode, nsString(in_responseMessage));
}
/*Notification for the response to the QUIT command.*/
void SMTPServerCallback_quit( smtpSink_t * in_pSink, int in_responseCode, const char * in_responseMessage )
{
nsISMTPObserver * obs = (nsISMTPObserver *) in_pSink->pOpaqueData;
if (nsnull != obs)
obs->ServerResponse(nsSMTPMethod_quit, in_responseCode, nsString(in_responseMessage));
}
/*Notification for the response to the RCPT TO command.*/
void SMTPServerCallback_rcptTo( smtpSink_t * in_pSink, int in_responseCode, const char * in_responseMessage )
{
nsISMTPObserver * obs = (nsISMTPObserver *) in_pSink->pOpaqueData;
if (nsnull != obs)
obs->ServerResponse(nsSMTPMethod_rcpTo, in_responseCode, nsString(in_responseMessage));
}
/*Notification for the response to the RSET command.*/
void SMTPServerCallback_reset( smtpSink_t * in_pSink, int in_responseCode, const char * in_responseMessage )
{
nsISMTPObserver * obs = (nsISMTPObserver *) in_pSink->pOpaqueData;
if (nsnull != obs)
obs->ServerResponse(nsSMTPMethod_reset, in_responseCode, nsString(in_responseMessage));
}
/*Notification for the response to sending the message.*/
void SMTPServerCallback_send( smtpSink_t * in_pSink, int in_responseCode, const char * in_responseMessage )
{
nsISMTPObserver * obs = (nsISMTPObserver *) in_pSink->pOpaqueData;
if (nsnull != obs)
obs->ServerResponse(nsSMTPMethod_send, in_responseCode, nsString(in_responseMessage));
}
/*Notification for the response to sending a generic command.*/
void SMTPServerCallback_sendCommand( smtpSink_t * in_pSink, int in_responseCode, const char * in_responseMessage )
{
nsISMTPObserver * obs = (nsISMTPObserver *) in_pSink->pOpaqueData;
if (nsnull != obs)
obs->ServerResponse(nsSMTPMethod_sendCommand, in_responseCode, nsString(in_responseMessage));
}
/*Notification for the completion of send a generic command.*/
void SMTPServerCallback_sendCommandComplete(smtpSink_t * in_pSink)
{
nsISMTPObserver * obs = (nsISMTPObserver *) in_pSink->pOpaqueData;
if (nsnull != obs)
obs->ServerResponse(nsSMTPMethod_sendCommandComplete, 0, nsString("SENDCOMMAND complete\n"));
}
/*Notification for the response to the VRFY command.*/
void SMTPServerCallback_verify( smtpSink_t * in_pSink, int in_responseCode, const char * in_responseMessage )
{
nsISMTPObserver * obs = (nsISMTPObserver *) in_pSink->pOpaqueData;
if (nsnull != obs)
obs->ServerResponse(nsSMTPMethod_verify, in_responseCode, nsString(in_responseMessage));
}

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

@ -24,30 +24,11 @@
#include <time.h>
#include <stdio.h>
#include "nsCRT.h"
#include "nsSMTPServerCallback.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kSMTPServiceIID, NS_ISMTP_SERVICE_IID);
void SMTPTest_bdat( smtpSink_t *, int, const char * );
void SMTPTest_connect( smtpSink_t *, int, const char * );
void SMTPTest_data( smtpSink_t *, int, const char * );
void SMTPTest_ehlo( smtpSink_t *, int, const char * );
void SMTPTest_ehloComplete(smtpSink_t *);
void SMTPTest_expand( smtpSink_t *, int, const char * );
void SMTPTest_expandComplete(smtpSink_t *);
void SMTPTest_help( smtpSink_t *, int, const char * );
void SMTPTest_helpComplete(smtpSink_t *);
void SMTPTest_mailFrom( smtpSink_t *, int, const char * );
void SMTPTest_noop( smtpSink_t *, int, const char * );
void SMTPTest_quit( smtpSink_t *, int, const char * );
void SMTPTest_rcptTo( smtpSink_t *, int, const char * );
void SMTPTest_reset( smtpSink_t *, int, const char * );
void SMTPTest_send( smtpSink_t *, int, const char * );
void SMTPTest_sendCommand( smtpSink_t *, int, const char * );
void SMTPTest_sendCommandComplete(smtpSink_t *);
void SMTPTest_verify( smtpSink_t *, int, const char * );
void setSink( smtpSink_t * pSink );
nsSMTPService :: nsSMTPService()
{
@ -67,7 +48,9 @@ nsresult nsSMTPService::Init()
return NS_OK;
}
nsresult nsSMTPService::SendMail(nsString& aServer, nsIMessage& aMessage)
nsresult nsSMTPService::SendMail(nsString& aServer,
nsIMessage& aMessage,
nsISMTPObserver * aObserver)
{
return NS_OK;
}
@ -76,265 +59,266 @@ nsresult nsSMTPService::SendMail(nsString& aServer,
nsString& aFrom,
nsString& aTo,
nsString& aSubject,
nsString& aBody)
nsString& aBody,
nsISMTPObserver * aObserver)
{
char * from = aFrom.ToNewCString();
char * to = aTo.ToNewCString();
char * header = aSubject.ToNewCString();
char * message = nsnull;
char * from = aFrom.ToNewCString();
char * to = aTo.ToNewCString();
char * header = aSubject.ToNewCString();
char * message = nsnull;
nsString data("Subject: ");
data += header;
data += "\r\n";
data += aBody.ToNewCString();
nsString data("Subject: ");
data += header;
data += "\r\n";
data += aBody.ToNewCString();
message = data.ToNewCString();
message = data.ToNewCString();
nsString strdomain ;
nsString strdomain ;
PRInt32 offset = aServer.Find("@");
aServer.Right(strdomain, aServer.Length() - offset);
char * domain = strdomain.ToNewCString();
PRInt32 offset = aServer.Find("@");
aServer.Right(strdomain, aServer.Length() - offset);
char * domain = strdomain.ToNewCString();
nsString strserver;
aServer.Left(strserver, offset);
char * server = strserver.ToNewCString();
nsString strserver;
aServer.Left(strserver, offset);
char * server = strserver.ToNewCString();
int l_nReturn;
nsmail_inputstream_t * l_inputStream;
smtpClient_t * pClient = NULL;
smtpSink_t * pSink = NULL;
int l_nReturn;
nsmail_inputstream_t * l_inputStream;
smtpClient_t * pClient = NULL;
smtpSink_t * pSink = NULL;
buf_inputStream_create (message, nsCRT::strlen(message), &l_inputStream);
buf_inputStream_create (message, nsCRT::strlen(message), &l_inputStream);
/*Initialize the response sink.*/
l_nReturn = smtpSink_initialize( &pSink );
/*Initialize the response sink.*/
l_nReturn = smtpSink_initialize( &pSink );
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
/*Set the function pointers on the response sink.*/
setSink( pSink );
setSink(pSink, aObserver);
/*Initialize the client passing in the response sink.*/
l_nReturn = smtp_initialize( &pClient, pSink );
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
/*Initialize the client passing in the response sink.*/
l_nReturn = smtp_initialize( &pClient, pSink );
/*Set the internal buffer chunk size.*/
l_nReturn = smtp_setChunkSize( pClient, 1048576 );
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
/*Set the internal buffer chunk size.*/
l_nReturn = smtp_setChunkSize( pClient, 1048576 );
/*Connect to the SMTP server.*/
l_nReturn = smtp_connect( pClient, server, 25 );
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
/*Connect to the SMTP server.*/
l_nReturn = smtp_connect( pClient, server, 25 );
l_nReturn = smtp_processResponses( pClient );
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
l_nReturn = smtp_processResponses( pClient );
/*Send the EHLO command passing in the domain name.*/
l_nReturn = smtp_ehlo( pClient, domain );
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
/*Send the EHLO command passing in the domain name.*/
l_nReturn = smtp_ehlo( pClient, domain );
l_nReturn = smtp_processResponses( pClient );
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
l_nReturn = smtp_processResponses( pClient );
/*Send the MAIL FROM command.*/
l_nReturn = smtp_mailFrom( pClient, from, NULL );
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
/*Send the MAIL FROM command.*/
l_nReturn = smtp_mailFrom( pClient, from, NULL );
l_nReturn = smtp_processResponses( pClient );
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
l_nReturn = smtp_processResponses( pClient );
/*Send the RCPT TO command.*/
l_nReturn = smtp_rcptTo( pClient, to, NULL );
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
/*Send the RCPT TO command.*/
l_nReturn = smtp_rcptTo( pClient, to, NULL );
l_nReturn = smtp_processResponses( pClient );
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
l_nReturn = smtp_processResponses( pClient );
/*Send the DATA command.*/
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
l_nReturn = smtp_data( pClient );
/*Send the DATA command.*/
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
l_nReturn = smtp_data( pClient );
l_nReturn = smtp_processResponses( pClient );
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
l_nReturn = smtp_processResponses( pClient );
/* Send the message.*/
l_nReturn = smtp_sendStream( pClient, l_inputStream );
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
/* Send the message.*/
l_nReturn = smtp_sendStream( pClient, l_inputStream );
l_nReturn = smtp_processResponses( pClient );
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
l_nReturn = smtp_processResponses( pClient );
/*Send the EXPN command.*/
l_nReturn = smtp_expand( pClient, from );
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
/*Send the EXPN command.*/
l_nReturn = smtp_expand( pClient, from );
l_nReturn = smtp_processResponses( pClient );
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
l_nReturn = smtp_processResponses( pClient );
/*Send the HELP command.*/
l_nReturn = smtp_help( pClient, from );
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
/*Send the HELP command.*/
l_nReturn = smtp_help( pClient, from );
l_nReturn = smtp_processResponses( pClient );
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
l_nReturn = smtp_processResponses( pClient );
/*Send the NOOP command.*/
l_nReturn = smtp_noop( pClient );
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
/*Send the NOOP command.*/
l_nReturn = smtp_noop( pClient );
l_nReturn = smtp_processResponses( pClient );
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
l_nReturn = smtp_processResponses( pClient );
/*Send the RSET command.*/
l_nReturn = smtp_reset( pClient );
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
/*Send the RSET command.*/
l_nReturn = smtp_reset( pClient );
l_nReturn = smtp_processResponses( pClient );
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
l_nReturn = smtp_processResponses( pClient );
/*Send the VRFY command.*/
l_nReturn = smtp_verify( pClient, from );
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
/*Send the VRFY command.*/
l_nReturn = smtp_verify( pClient, from );
l_nReturn = smtp_processResponses( pClient );
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
l_nReturn = smtp_processResponses( pClient );
/*Send a generic command to the server.*/
l_nReturn = smtp_sendCommand( pClient, "HELP help" );
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
/*Send a generic command to the server.*/
l_nReturn = smtp_sendCommand( pClient, "HELP help" );
l_nReturn = smtp_processResponses( pClient );
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
l_nReturn = smtp_processResponses( pClient );
l_nReturn = smtp_quit( pClient );
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
l_nReturn = smtp_quit( pClient );
l_nReturn = smtp_processResponses( pClient );
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
l_nReturn = smtp_processResponses( pClient );
nsStream_free (l_inputStream);
if ( l_nReturn != NSMAIL_OK )
{
return l_nReturn;
}
/*Free the client structure.*/
smtp_free( &pClient );
/*Free the sink structure.*/
smtpSink_free( &pSink );
nsStream_free (l_inputStream);
/*Free the client structure.*/
smtp_free( &pClient );
/*Free the sink structure.*/
smtpSink_free( &pSink );
delete server;
delete from;
@ -350,145 +334,3 @@ nsresult nsSMTPService::SendMail(nsString& aServer,
/*Function to set the sink pointers.*/
void setSink( smtpSink_t * pSink )
{
pSink->bdat = SMTPTest_bdat;
pSink->connect = SMTPTest_connect;
pSink->data = SMTPTest_data;
pSink->ehlo = SMTPTest_ehlo;
pSink->ehloComplete = SMTPTest_ehloComplete;
pSink->expand = SMTPTest_expand;
pSink->expandComplete = SMTPTest_expandComplete;
pSink->help = SMTPTest_help;
pSink->helpComplete = SMTPTest_helpComplete;
pSink->mailFrom = SMTPTest_mailFrom;
pSink->noop = SMTPTest_noop;
pSink->quit = SMTPTest_quit;
pSink->rcptTo = SMTPTest_rcptTo;
pSink->reset = SMTPTest_reset;
pSink->send = SMTPTest_send;
pSink->sendCommand = SMTPTest_sendCommand;
pSink->sendCommandComplete = SMTPTest_sendCommandComplete;
pSink->verify = SMTPTest_verify;
}
/*Notification for the response to the BDAT command.*/
void SMTPTest_bdat( smtpSink_t * in_pSink, int in_responseCode, const char * in_responseMessage )
{
printf( "%d %s\n", in_responseCode, in_responseMessage );
}
/*Notification for the response to the connection to the server.*/
void SMTPTest_connect( smtpSink_t * in_pSink, int in_responseCode, const char * in_responseMessage )
{
printf( "%d %s\n", in_responseCode, in_responseMessage );
}
/*Notification for the response to the DATA command.*/
void SMTPTest_data( smtpSink_t * in_pSink, int in_responseCode, const char * in_responseMessage )
{
printf( "%d %s\n", in_responseCode, in_responseMessage );
}
/*Notification for the response to the EHLO command.*/
void SMTPTest_ehlo( smtpSink_t * in_pSink, int in_responseCode, const char * in_responseMessage )
{
printf( "%d %s\n", in_responseCode, in_responseMessage );
}
/*Notification for the completion of the EHLO command.*/
void SMTPTest_ehloComplete(smtpSink_t * in_pSink)
{
printf( "EHLO complete\n" );
}
/*Notification for the response to a server error.*/
void SMTPTest_error(smtpSink_t * in_pSink, int in_responseCode, const char * in_responseMessage )
{
printf( "%d %s\n", in_responseCode, in_responseMessage );
}
/*Notification for the response to the EXPN command.*/
void SMTPTest_expand( smtpSink_t * in_pSink, int in_responseCode, const char * in_responseMessage )
{
printf( "%d %s\n", in_responseCode, in_responseMessage );
}
/*Notification for the completion of the EXPN command.*/
void SMTPTest_expandComplete(smtpSink_t * in_pSink)
{
printf( "EXPAND complete\n" );
}
/*Notification for the response to the HELP command.*/
void SMTPTest_help( smtpSink_t * in_pSink, int in_responseCode, const char * in_responseMessage )
{
printf( "%d %s\n", in_responseCode, in_responseMessage );
}
/*Notification for the completion of the HELP command.*/
void SMTPTest_helpComplete(smtpSink_t * in_pSink)
{
printf( "HELP complete\n" );
}
/*Notification for the response to the MAIL FROM command.*/
void SMTPTest_mailFrom( smtpSink_t * in_pSink, int in_responseCode, const char * in_responseMessage )
{
printf( "%d %s\n", in_responseCode, in_responseMessage );
}
/*Notification for the response to the NOOP command.*/
void SMTPTest_noop( smtpSink_t * in_pSink, int in_responseCode, const char * in_responseMessage )
{
printf( "%d %s\n", in_responseCode, in_responseMessage );
}
/*Notification for the response to the QUIT command.*/
void SMTPTest_quit( smtpSink_t * in_pSink, int in_responseCode, const char * in_responseMessage )
{
printf( "%d %s\n", in_responseCode, in_responseMessage );
}
/*Notification for the response to the RCPT TO command.*/
void SMTPTest_rcptTo( smtpSink_t * in_pSink, int in_responseCode, const char * in_responseMessage )
{
printf( "%d %s\n", in_responseCode, in_responseMessage );
}
/*Notification for the response to the RSET command.*/
void SMTPTest_reset( smtpSink_t * in_pSink, int in_responseCode, const char * in_responseMessage )
{
printf( "%d %s\n", in_responseCode, in_responseMessage );
}
/*Notification for the response to sending the message.*/
void SMTPTest_send( smtpSink_t * in_pSink, int in_responseCode, const char * in_responseMessage )
{
printf( "%d %s\n", in_responseCode, in_responseMessage );
}
/*Notification for the response to sending a generic command.*/
void SMTPTest_sendCommand( smtpSink_t * in_pSink, int in_responseCode, const char * in_responseMessage )
{
printf( "%d %s\n", in_responseCode, in_responseMessage );
}
/*Notification for the completion of send a generic command.*/
void SMTPTest_sendCommandComplete(smtpSink_t * in_pSink)
{
printf( "SENDCOMMAND complete\n" );
}
/*Notification for the response to the VRFY command.*/
void SMTPTest_verify( smtpSink_t * in_pSink, int in_responseCode, const char * in_responseMessage )
{
printf( "%d %s\n", in_responseCode, in_responseMessage );
}