Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Functions
nsSmtpService.cpp File Reference
#include "msgCore.h"
#include "nsXPIDLString.h"
#include "nsReadableUtils.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsIIOService.h"
#include "nsIPipe.h"
#include "nsNetCID.h"
#include "nsEscape.h"
#include "nsNetUtil.h"
#include "nsSmtpService.h"
#include "nsIMsgMailSession.h"
#include "nsMsgBaseCID.h"
#include "nsMsgCompCID.h"
#include "nsSmtpUrl.h"
#include "nsSmtpProtocol.h"
#include "nsIFileSpec.h"
#include "nsCOMPtr.h"
#include "nsIMsgIdentity.h"
#include "nsMsgComposeStringBundle.h"
#include "nsIPrompt.h"
#include "nsIWindowWatcher.h"
#include "nsMsgSimulateError.h"
#include "nsIUTF8ConverterService.h"
#include "nsUConvCID.h"

Go to the source code of this file.

Classes

struct  _findServerByKeyEntry
struct  _findServerByHostnameEntry

Defines

#define SERVER_DELIMITER   ","
#define APPEND_SERVERS_VERSION_PREF_NAME   "append_preconfig_smtpservers.version"
#define MAIL_ROOT_PREF   "mail."
#define PREF_MAIL_SMTPSERVERS   "mail.smtpservers"
#define PREF_MAIL_SMTPSERVERS_APPEND_SERVERS   "mail.smtpservers.appendsmtpservers"
#define PREF_MAIL_SMTP_DEFAULTSERVER   "mail.smtp.defaultserver"

Typedefs

typedef struct
_findServerByKeyEntry 
findServerByKeyEntry
typedef struct
_findServerByHostnameEntry 
findServerByHostnameEntry

Functions

static NS_DEFINE_CID (kCSmtpUrlCID, NS_SMTPURL_CID)
static NS_DEFINE_CID (kCMailtoUrlCID, NS_MAILTOURL_CID)
nsresult NS_MsgBuildSmtpUrl (nsIFileSpec *aFilePath, const char *aSmtpHostName, PRInt32 aSmtpPort, const char *aSmtpUserName, const char *aRecipients, nsIMsgIdentity *aSenderIdentity, nsIUrlListener *aUrlListener, nsIMsgStatusFeedback *aStatusFeedback, nsIInterfaceRequestor *aNotificationCallbacks, nsIURI **aUrl)
nsresult NS_MsgLoadSmtpUrl (nsIURI *aUrl, nsISupports *aConsumer, nsIRequest **aRequest)

Class Documentation

struct _findServerByKeyEntry

Definition at line 128 of file nsMsgAccountManager.cpp.

Collaboration diagram for _findServerByKeyEntry:
Class Members
PRInt32 index
const char * key
nsISmtpServer * server
struct _findServerByHostnameEntry

Definition at line 79 of file nsSmtpService.cpp.

Collaboration diagram for _findServerByHostnameEntry:
Class Members
const char * hostname
nsISmtpServer * server
const char * username

Define Documentation

#define APPEND_SERVERS_VERSION_PREF_NAME   "append_preconfig_smtpservers.version"

Definition at line 68 of file nsSmtpService.cpp.

#define MAIL_ROOT_PREF   "mail."

Definition at line 69 of file nsSmtpService.cpp.

#define PREF_MAIL_SMTP_DEFAULTSERVER   "mail.smtp.defaultserver"

Definition at line 72 of file nsSmtpService.cpp.

#define PREF_MAIL_SMTPSERVERS   "mail.smtpservers"

Definition at line 70 of file nsSmtpService.cpp.

#define PREF_MAIL_SMTPSERVERS_APPEND_SERVERS   "mail.smtpservers.appendsmtpservers"

Definition at line 71 of file nsSmtpService.cpp.

Definition at line 67 of file nsSmtpService.cpp.


Typedef Documentation


Function Documentation

static NS_DEFINE_CID ( kCSmtpUrlCID  ,
NS_SMTPURL_CID   
) [static]
static NS_DEFINE_CID ( kCMailtoUrlCID  ,
NS_MAILTOURL_CID   
) [static]
nsresult NS_MsgBuildSmtpUrl ( nsIFileSpec aFilePath,
const char *  aSmtpHostName,
PRInt32  aSmtpPort,
const char *  aSmtpUserName,
const char *  aRecipients,
nsIMsgIdentity aSenderIdentity,
nsIUrlListener aUrlListener,
nsIMsgStatusFeedback aStatusFeedback,
nsIInterfaceRequestor aNotificationCallbacks,
nsIURI **  aUrl 
)

Definition at line 186 of file nsSmtpService.cpp.

{
    // mscott: this function is a convience hack until netlib actually dispatches smtp urls.
    // in addition until we have a session to get a password, host and other stuff from, we need to use default values....
    // ..for testing purposes....

    nsresult rv = NS_OK;
    nsCOMPtr <nsISmtpUrl> smtpUrl (do_CreateInstance(kCSmtpUrlCID, &rv));

    if (NS_SUCCEEDED(rv) && smtpUrl)
    {
        nsCAutoString urlSpec("smtp://");
        if (aSmtpUserName) 
        {
            nsXPIDLCString escapedUsername;
            *((char **)getter_Copies(escapedUsername)) = nsEscape(aSmtpUserName, url_XAlphas);
            urlSpec += escapedUsername;
            urlSpec += '@';
        }

        urlSpec += aSmtpHostName;
        if (!PL_strchr(aSmtpHostName, ':'))
        {
            urlSpec += ':';
            urlSpec.AppendInt(aSmtpPort);
        }

        if (urlSpec.get())
        {
            nsCOMPtr<nsIMsgMailNewsUrl> url = do_QueryInterface(smtpUrl);
            url->SetSpec(urlSpec);
            smtpUrl->SetRecipients(aRecipients);
            smtpUrl->SetPostMessageFile(aFilePath);
            smtpUrl->SetSenderIdentity(aSenderIdentity);
            smtpUrl->SetNotificationCallbacks(aNotificationCallbacks);

            nsCOMPtr<nsIPrompt> smtpPrompt(do_GetInterface(aNotificationCallbacks));
            nsCOMPtr<nsIAuthPrompt> smtpAuthPrompt(do_GetInterface(aNotificationCallbacks));
            if (!smtpPrompt || !smtpAuthPrompt)
            {
                nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
                if (wwatch) {
                    if (!smtpPrompt)
                        wwatch->GetNewPrompter(0, getter_AddRefs(smtpPrompt));
                    if (!smtpAuthPrompt)
                        wwatch->GetNewAuthPrompter(0, getter_AddRefs(smtpAuthPrompt));
                }
            }
            smtpUrl->SetPrompt(smtpPrompt);            
            smtpUrl->SetAuthPrompt(smtpAuthPrompt);
            url->RegisterListener(aUrlListener);
            if (aStatusFeedback)
                url->SetStatusFeedback(aStatusFeedback);
        }
        rv = smtpUrl->QueryInterface(NS_GET_IID(nsIURI), (void **) aUrl);
    }

    return rv;
}

Here is the call graph for this function:

nsresult NS_MsgLoadSmtpUrl ( nsIURI aUrl,
nsISupports *  aConsumer,
nsIRequest **  aRequest 
)

Definition at line 255 of file nsSmtpService.cpp.

{
    // for now, assume the url is an smtp url and load it....
    nsCOMPtr <nsISmtpUrl> smtpUrl;
    nsSmtpProtocol   *smtpProtocol = nsnull;
    nsresult rv = NS_OK;

    if (!aUrl)
        return rv;

    // turn the url into an smtp url...
    smtpUrl = do_QueryInterface(aUrl);
    if (smtpUrl)
    {
        // almost there...now create a smtp protocol instance to run the url in...
        smtpProtocol = new nsSmtpProtocol(aUrl);
        if (smtpProtocol == nsnull)
            return NS_ERROR_OUT_OF_MEMORY;

        NS_ADDREF(smtpProtocol);
        rv = smtpProtocol->LoadUrl(aUrl, aConsumer); // protocol will get destroyed when url is completed...
        smtpProtocol->QueryInterface(NS_GET_IID(nsIRequest), (void **) aRequest);
        NS_RELEASE(smtpProtocol);
    }

    return rv;
}

Here is the call graph for this function: