Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Member Functions
nsPop3Service Class Reference

#include <nsPop3Service.h>

Inheritance diagram for nsPop3Service:
Inheritance graph
[legend]
Collaboration diagram for nsPop3Service:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsPop3Service ()
virtual ~nsPop3Service ()
nsIURI GetNewMail (in nsIMsgWindow aMsgWindow, in nsIUrlListener aUrlListener, in nsIMsgFolder aInbox, in nsIPop3IncomingServer popServer)
nsIURI CheckForNewMail (in nsIMsgWindow aMsgWindow, in nsIUrlListener aUrlListener, in nsIMsgFolder inbox, in nsIPop3IncomingServer popServer)
nsIURI newURI (in AUTF8String aSpec, in string aOriginCharset, in nsIURI aBaseURI)
 Makes a URI object that is suitable for loading by this protocol, where the URI string is given as an UTF-8 string.
nsIChannel newChannel (in nsIURI aURI)
 Constructs a new channel from the given URI for this protocol handler.
boolean allowPort (in long port, in string scheme)
 Allows a protocol to override blacklisted ports.
long getDefaultServerPort (in boolean isSecure)

Public Attributes

readonly attribute ACString scheme
 The scheme of this protocol (e.g., "file").
readonly attribute long defaultPort
 The default port is the port that this protocol normally uses.
readonly attribute unsigned long protocolFlags
 Returns the protocol specific flags (see flag definitions below).
const unsigned long URI_STD = 0
 standard full URI with authority component and concept of relative URIs (http, ftp, ...)
const unsigned long URI_NORELATIVE = (1<<0)
 no concept of relative URIs (about, javascript, finger, ...)
const unsigned long URI_NOAUTH = (1<<1)
 no authority component (file, ...)
const unsigned long ALLOWS_PROXY = (1<<2)
 This protocol handler can be proxied via a proxy (socks or http) (e.g., irc, smtp, http, etc.).
const unsigned long ALLOWS_PROXY_HTTP = (1<<3)
 This protocol handler can be proxied using a http proxy (e.g., http, ftp, etc.).
attribute nsIFileSpec defaultLocalPath
 the default path to store local data for this type of server.
readonly attribute nsIIDPtr serverIID
 the IID of the protocol-specific interface for this server usually used from JS to dynamically get server-specific attributes
readonly attribute boolean requiresUsername
 does this server type require a username? for instance, news does not but IMAP/POP do
readonly attribute boolean preflightPrettyNameWithEmailAddress
 if the pretty name of the server should just be the e-mail address.
readonly attribute boolean canDelete
 can this type of server be removed from the account manager? for instance, local mail is not removable
readonly attribute boolean canLoginAtStartUp
 can this type of server log in at startup?
readonly attribute boolean canDuplicate
 can you duplicate this server? for instance, local mail is unique and should not be duplicated.
readonly attribute boolean canGetMessages
 An attribute that tell us whether on not we can get messages for the given server type this is poorly named right now.
readonly attribute boolean canGetIncomingMessages
 do messages arrive for this server if they do, we can use our junk controls on it.
readonly attribute boolean defaultDoBiff
 do biff by default?
readonly attribute boolean showComposeMsgLink
 do we need to show compose message link in the AccountCentral page ?
readonly attribute boolean needToBuildSpecialFolderURIs
 do we need to build special folder URIs ? In case of IMAP, special folders like 'Sent', 'Drafts' and 'Templates' are not created unless needed.
readonly attribute boolean specialFoldersDeletionAllowed
 do we allow special folder deletion ?

Protected Member Functions

nsresult GetMail (PRBool downloadNewMail, nsIMsgWindow *aMsgWindow, nsIUrlListener *aUrlListener, nsIMsgFolder *inbox, nsIPop3IncomingServer *popServer, nsIURI **aURL)
nsresult BuildPop3Url (const char *urlSpec, nsIMsgFolder *inbox, nsIPop3IncomingServer *, nsIUrlListener *aUrlListener, nsIURI **aUrl, nsIMsgWindow *aMsgWindow)
nsresult RunPopUrl (nsIMsgIncomingServer *aServer, nsIURI *aUrlToRun)
void AlertServerBusy (nsIMsgMailNewsUrl *url)

Detailed Description

Definition at line 53 of file nsPop3Service.h.


Constructor & Destructor Documentation

Definition at line 79 of file nsPop3Service.cpp.

{
}

Definition at line 83 of file nsPop3Service.cpp.

{}

Member Function Documentation

Definition at line 422 of file nsPop3Service.cpp.

{
  nsCOMPtr <nsIMsgStringService> stringService = do_GetService(NS_MSG_POPSTRINGSERVICE_CONTRACTID);
  nsCOMPtr<nsIMsgWindow> msgWindow;
  nsCOMPtr<nsIPrompt> dialog;
  nsresult rv = url->GetMsgWindow(getter_AddRefs(msgWindow)); //it is ok to have null msgWindow, for example when biffing
  if (NS_SUCCEEDED(rv) && msgWindow)
  {
    rv = msgWindow->GetPromptDialog(getter_AddRefs(dialog));
    if (NS_SUCCEEDED(rv))
    {
      nsXPIDLString alertString;
      stringService->GetStringByID(POP3_MESSAGE_FOLDER_BUSY, getter_Copies(alertString));
      if (!alertString.IsEmpty())
        dialog->Alert(nsnull, alertString.get()); 
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

boolean nsIProtocolHandler::allowPort ( in long  port,
in string  scheme 
) [inherited]

Allows a protocol to override blacklisted ports.

This method will be called when there is an attempt to connect to a port that is blacklisted. For example, for most protocols, port 25 (Simple Mail Transfer) is banned. When a URI containing this "known-to-do-bad-things" port number is encountered, this function will be called to ask if the protocol handler wants to override the ban.

nsresult nsPop3Service::BuildPop3Url ( const char *  urlSpec,
nsIMsgFolder inbox,
nsIPop3IncomingServer server,
nsIUrlListener aUrlListener,
nsIURI **  aUrl,
nsIMsgWindow aMsgWindow 
) [protected]

Definition at line 177 of file nsPop3Service.cpp.

{
  nsresult rv;
  
  nsPop3Sink * pop3Sink = new nsPop3Sink();
  if (pop3Sink)
  {
    pop3Sink->SetPopServer(server);
    pop3Sink->SetFolder(inbox);
  }
  
  // now create a pop3 url and a protocol instance to run the url....
  nsCOMPtr<nsIPop3URL> pop3Url = do_CreateInstance(kPop3UrlCID, &rv);
  NS_ENSURE_SUCCESS(rv,rv);
    
  pop3Url->SetPop3Sink(pop3Sink);
    
  rv = pop3Url->QueryInterface(NS_GET_IID(nsIURI), (void **) aUrl);
  NS_ENSURE_SUCCESS(rv,rv);
    
  (*aUrl)->SetSpec(nsDependentCString(urlSpec));
    
  nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(pop3Url);
  if (mailnewsurl)
  {
    if (aUrlListener)
      mailnewsurl->RegisterListener(aUrlListener);
    if (aMsgWindow)
      mailnewsurl->SetMsgWindow(aMsgWindow);
  }
    
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIURI nsIPop3Service::CheckForNewMail ( in nsIMsgWindow  aMsgWindow,
in nsIUrlListener  aUrlListener,
in nsIMsgFolder  inbox,
in nsIPop3IncomingServer  popServer 
) [inherited]
nsresult nsPop3Service::GetMail ( PRBool  downloadNewMail,
nsIMsgWindow aMsgWindow,
nsIUrlListener aUrlListener,
nsIMsgFolder inbox,
nsIPop3IncomingServer popServer,
nsIURI **  aURL 
) [protected]

Definition at line 109 of file nsPop3Service.cpp.

{

  NS_ENSURE_ARG_POINTER(aInbox);
  nsXPIDLCString popHost;
  nsXPIDLCString popUser;
  PRInt32 popPort = -1;
  
  nsCOMPtr<nsIMsgIncomingServer> server;
  nsCOMPtr<nsIURI> url;
  
  server = do_QueryInterface(aPopServer);
  
  nsCOMPtr <nsIMsgLocalMailFolder> destLocalFolder = do_QueryInterface(aInbox);
  if (destLocalFolder)
  {
    PRBool destFolderTooBig;
    destLocalFolder->WarnIfLocalFileTooBig(aMsgWindow, &destFolderTooBig);
    if (destFolderTooBig)
      return NS_MSG_ERROR_WRITING_MAIL_FOLDER;
  }

  if (!server) 
    return NS_MSG_INVALID_OR_MISSING_SERVER;
  
  nsresult rv = server->GetHostName(getter_Copies(popHost));
  NS_ENSURE_SUCCESS(rv, rv);
  if (!((const char *)popHost)) 
    return NS_MSG_INVALID_OR_MISSING_SERVER;
  
  rv = server->GetPort(&popPort);
  NS_ENSURE_SUCCESS(rv, rv);
  
  rv = server->GetUsername(getter_Copies(popUser));
  NS_ENSURE_SUCCESS(rv, rv);
  if (!((const char *)popUser)) 
    return NS_MSG_SERVER_USERNAME_MISSING;
  
  nsXPIDLCString escapedUsername;
  *((char**)getter_Copies(escapedUsername)) = nsEscape(popUser, url_XAlphas);
  
  if (NS_SUCCEEDED(rv) && aPopServer)
  {
    // now construct a pop3 url...
    // we need to escape the username because it may contain
    // characters like / % or @
    char * urlSpec = (downloadNewMail)
      ? PR_smprintf("pop3://%s@%s:%d", (const char *)escapedUsername, (const char *)popHost, popPort)
      : PR_smprintf("pop3://%s@%s:%d/?check", (const char *)escapedUsername, (const char *)popHost, popPort);
    rv = BuildPop3Url(urlSpec, aInbox, aPopServer, aUrlListener, getter_AddRefs(url), aMsgWindow);
    PR_Free(urlSpec);
  }
  
  
  if (NS_SUCCEEDED(rv) && url) 
    rv = RunPopUrl(server, url);
  
  if (aURL && url) // we already have a ref count on pop3url...
    NS_IF_ADDREF(*aURL = url);
  
  return rv;
}

Here is the call graph for this function:

nsIURI nsIPop3Service::GetNewMail ( in nsIMsgWindow  aMsgWindow,
in nsIUrlListener  aUrlListener,
in nsIMsgFolder  aInbox,
in nsIPop3IncomingServer  popServer 
) [inherited]

Constructs a new channel from the given URI for this protocol handler.

nsIURI nsIProtocolHandler::newURI ( in AUTF8String  aSpec,
in string  aOriginCharset,
in nsIURI  aBaseURI 
) [inherited]

Makes a URI object that is suitable for loading by this protocol, where the URI string is given as an UTF-8 string.

The caller may provide the charset from which the URI string originated, so that the URI string can be translated back to that charset (if necessary) before communicating with, for example, the origin server of the URI string. (Many servers do not support UTF-8 IRIs at the present time, so we must be careful about tracking the native charset of the origin server.)

Parameters:
aSpec- the URI string in UTF-8 encoding. depending on the protocol implementation, unicode character sequences may or may not be xx escaped.
aOriginCharset- the charset of the document from which this URI string originated. this corresponds to the charset that should be used when communicating this URI to an origin server, for example. if null, then UTF-8 encoding is assumed (i.e., no charset transformation from aSpec).
aBaseURI- if null, aSpec must specify an absolute URI. otherwise, aSpec may be resolved relative to aBaseURI, depending on the protocol. If the protocol has no concept of relative URI aBaseURI will simply be ignored.
nsresult nsPop3Service::RunPopUrl ( nsIMsgIncomingServer aServer,
nsIURI aUrlToRun 
) [protected]

Definition at line 216 of file nsPop3Service.cpp.

{
  nsresult rv = NS_OK;
  if (aServer && aUrlToRun)
  {
    nsXPIDLCString userName;
    
    // load up required server information
    // we store the username unescaped in the server
    // so there is no need to unescape it
    rv = aServer->GetRealUsername(getter_Copies(userName));
    
    // find out if the server is busy or not...if the server is busy, we are 
    // *NOT* going to run the url
    PRBool serverBusy = PR_FALSE;
    rv = aServer->GetServerBusy(&serverBusy);
    
    if (!serverBusy)
    {
      nsPop3Protocol * protocol = new nsPop3Protocol(aUrlToRun);
      if (protocol)
      {
        NS_ADDREF(protocol);
        rv = protocol->Initialize(aUrlToRun);
        if(NS_FAILED(rv))
        {
          delete protocol;
          return rv;
        }
        // the protocol stores the unescaped username, so there is no need to escape it.
        protocol->SetUsername(userName);
        rv = protocol->LoadUrl(aUrlToRun);
        NS_RELEASE(protocol);
        if (NS_FAILED(rv))
          aServer->SetServerBusy(PR_FALSE);
      }
    } 
    else
    {
      nsCOMPtr <nsIMsgMailNewsUrl> url = do_QueryInterface(aUrlToRun);
      if (url)
        AlertServerBusy(url);
      rv = NS_ERROR_FAILURE;
    }
  } // if server
  
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

const unsigned long nsIProtocolHandler::ALLOWS_PROXY = (1<<2) [inherited]

This protocol handler can be proxied via a proxy (socks or http) (e.g., irc, smtp, http, etc.).

If the protocol supports transparent proxying, the handler should implement nsIProxiedProtocolHandler.

If it supports only HTTP proxying, then it need not support nsIProxiedProtocolHandler, but should instead set the ALLOWS_PROXY_HTTP flag (see below).

See also:
nsIProxiedProtocolHandler

Definition at line 148 of file nsIProtocolHandler.idl.

const unsigned long nsIProtocolHandler::ALLOWS_PROXY_HTTP = (1<<3) [inherited]

This protocol handler can be proxied using a http proxy (e.g., http, ftp, etc.).

nsIIOService::newChannelFromURI will feed URIs from this protocol handler to the HTTP protocol handler instead. This flag is ignored if ALLOWS_PROXY is not set.

Definition at line 156 of file nsIProtocolHandler.idl.

can this type of server be removed from the account manager? for instance, local mail is not removable

Definition at line 80 of file nsIMsgProtocolInfo.idl.

can you duplicate this server? for instance, local mail is unique and should not be duplicated.

Definition at line 91 of file nsIMsgProtocolInfo.idl.

do messages arrive for this server if they do, we can use our junk controls on it.

Definition at line 114 of file nsIMsgProtocolInfo.idl.

An attribute that tell us whether on not we can get messages for the given server type this is poorly named right now.

it's really is there an inbox for this type? XXX todo, rename this.

Definition at line 108 of file nsIMsgProtocolInfo.idl.

can this type of server log in at startup?

Definition at line 85 of file nsIMsgProtocolInfo.idl.

do biff by default?

Definition at line 119 of file nsIMsgProtocolInfo.idl.

the default path to store local data for this type of server.

Each server is usually in a subdirectory below this

Definition at line 55 of file nsIMsgProtocolInfo.idl.

The default port is the port that this protocol normally uses.

If a port does not make sense for the protocol (e.g., "about:") then -1 will be returned.

Definition at line 61 of file nsIProtocolHandler.idl.

do we need to build special folder URIs ? In case of IMAP, special folders like 'Sent', 'Drafts' and 'Templates' are not created unless needed.

But, we do need to create folder URIs to reflect the choices in the UI in copies and folders settings panel.

Definition at line 132 of file nsIMsgProtocolInfo.idl.

if the pretty name of the server should just be the e-mail address.

Otherwise it usually ends up being something like "news on hostname"

Definition at line 74 of file nsIMsgProtocolInfo.idl.

readonly attribute unsigned long nsIProtocolHandler::protocolFlags [inherited]

Returns the protocol specific flags (see flag definitions below).

Definition at line 66 of file nsIProtocolHandler.idl.

does this server type require a username? for instance, news does not but IMAP/POP do

Definition at line 67 of file nsIMsgProtocolInfo.idl.

readonly attribute ACString nsIProtocolHandler::scheme [inherited]

The scheme of this protocol (e.g., "file").

Definition at line 54 of file nsIProtocolHandler.idl.

readonly attribute nsIIDPtr nsIMsgProtocolInfo::serverIID [inherited]

the IID of the protocol-specific interface for this server usually used from JS to dynamically get server-specific attributes

Definition at line 61 of file nsIMsgProtocolInfo.idl.

do we need to show compose message link in the AccountCentral page ?

Definition at line 124 of file nsIMsgProtocolInfo.idl.

do we allow special folder deletion ?

Definition at line 137 of file nsIMsgProtocolInfo.idl.

const unsigned long nsIProtocolHandler::URI_NOAUTH = (1<<1) [inherited]

no authority component (file, ...)

Definition at line 135 of file nsIProtocolHandler.idl.

const unsigned long nsIProtocolHandler::URI_NORELATIVE = (1<<0) [inherited]

no concept of relative URIs (about, javascript, finger, ...)

Definition at line 130 of file nsIProtocolHandler.idl.

const unsigned long nsIProtocolHandler::URI_STD = 0 [inherited]

standard full URI with authority component and concept of relative URIs (http, ftp, ...)

Definition at line 125 of file nsIProtocolHandler.idl.


The documentation for this class was generated from the following files: