Back to index

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

#include <nsMailboxService.h>

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

List of all members.

Public Member Functions

 nsMailboxService ()
virtual ~nsMailboxService ()
nsIURI ParseMailbox (in nsIMsgWindow aMsgWindow, in nsFileSpec aMailboxPath, in nsIStreamListener aMailboxParser, in nsIUrlListener aUrlListener)
void CopyMessage (in string aSrcURI, in nsIStreamListener aCopyListener, in boolean aMoveMessage, in nsIUrlListener aUrlListener, in nsIMsgWindow aMsgWindow, out nsIURI aURL)
void CopyMessages (in nsMsgKeyArrayPtr keys, in nsIMsgFolder srcFolder, in nsIStreamListener aCopyListener, in boolean aMoveMessage, in nsIUrlListener aUrlListener, in nsIMsgWindow aMsgWindow, out nsIURI aURL)
void DisplayMessage (in string aMessageURI, in nsISupports aDisplayConsumer, in nsIMsgWindow aMsgWindow, in nsIUrlListener aUrlListener, in string aCharsetOverride, out nsIURI aURL)
void openAttachment (in string aContentType, in string aFileName, in string aUrl, in string aMessageUri, in nsISupports aDisplayConsumer, in nsIMsgWindow aMsgWindow, in nsIUrlListener aUrlListener)
void SaveMessageToDisk (in string aMessageURI, in nsIFileSpec aFile, in boolean aGenerateDummyEnvelope, in nsIUrlListener aUrlListener, out nsIURI aURL, in boolean canonicalLineEnding, in nsIMsgWindow aMsgWindow)
void GetUrlForUri (in string aMessageURI, out nsIURI aURL, in nsIMsgWindow aMsgWindow)
void DisplayMessageForPrinting (in string aMessageURI, in nsISupports aDisplayConsumer, in nsIMsgWindow aMsgWindow, in nsIUrlListener aUrlListener, out nsIURI aURL)
void Search (in nsIMsgSearchSession aSearchSession, in nsIMsgWindow aMsgWindow, in nsIMsgFolder aMsgFolder, in string aSearchUri)
nsIURI streamMessage (in string aMessageURI, in nsISupports aConsumer, in nsIMsgWindow aMsgWindow, in nsIUrlListener aUrlListener, in boolean aConvertData, in string aAdditionalHeader)
nsIMsgDBHdr messageURIToMsgHdr (in string uri)
 now the the message datasource is going away we need away to go from message uri to go nsIMsgDBHdr
nsIURI fetchMimePart (in nsIURI aURI, in string aMessageUri, in nsISupports aDisplayConsumer, in nsIMsgWindow aMsgWindow, in nsIUrlListener aUrlListener)
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.

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.).

Protected Member Functions

nsresult PrepareMessageUrl (const char *aSrcMsgMailboxURI, nsIUrlListener *aUrlListener, nsMailboxAction aMailboxAction, nsIMailboxUrl **aMailboxUrl, nsIMsgWindow *msgWindow)
nsresult RunMailboxUrl (nsIURI *aMailboxUrl, nsISupports *aDisplayConsumer=nsnull)
nsresult FetchMessage (const char *aMessageURI, nsISupports *aDisplayConsumer, nsIMsgWindow *aMsgWindow, nsIUrlListener *aUrlListener, const char *aFileName, nsMailboxAction mailboxAction, const char *aCharsetOverride, nsIURI **aURL)
nsresult DecomposeMailboxURI (const char *aMessageURI, nsIMsgFolder **aFolder, nsMsgKey *aMsgKey)

Protected Attributes

PRBool mPrintingOperation

Detailed Description

Definition at line 55 of file nsMailboxService.h.


Constructor & Destructor Documentation

Definition at line 67 of file nsMailboxService.cpp.

Definition at line 72 of file nsMailboxService.cpp.

{}

Member Function Documentation

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.

void nsIMsgMessageService::CopyMessage ( in string  aSrcURI,
in nsIStreamListener  aCopyListener,
in boolean  aMoveMessage,
in nsIUrlListener  aUrlListener,
in nsIMsgWindow  aMsgWindow,
out nsIURI  aURL 
) [inherited]
void nsIMsgMessageService::CopyMessages ( in nsMsgKeyArrayPtr  keys,
in nsIMsgFolder  srcFolder,
in nsIStreamListener  aCopyListener,
in boolean  aMoveMessage,
in nsIUrlListener  aUrlListener,
in nsIMsgWindow  aMsgWindow,
out nsIURI  aURL 
) [inherited]
nsresult nsMailboxService::DecomposeMailboxURI ( const char *  aMessageURI,
nsIMsgFolder **  aFolder,
nsMsgKey aMsgKey 
) [protected]

Definition at line 603 of file nsMailboxService.cpp.

{
  NS_ENSURE_ARG_POINTER(aMessageURI);
  NS_ENSURE_ARG_POINTER(aFolder);
  NS_ENSURE_ARG_POINTER(aMsgKey);
  
  nsresult rv = NS_OK;
  nsCAutoString folderURI;
  rv = nsParseLocalMessageURI(aMessageURI, folderURI, aMsgKey);
  NS_ENSURE_SUCCESS(rv,rv);

  nsCOMPtr <nsIRDFService> rdf = do_GetService("@mozilla.org/rdf/rdf-service;1",&rv);
  NS_ENSURE_SUCCESS(rv,rv);

  nsCOMPtr<nsIRDFResource> res;
  rv = rdf->GetResource(folderURI, getter_AddRefs(res));
  NS_ENSURE_SUCCESS(rv,rv);

  rv = res->QueryInterface(NS_GET_IID(nsIMsgFolder), (void **) aFolder);
  NS_ENSURE_SUCCESS(rv,rv);

  return NS_OK;
}

Here is the call graph for this function:

void nsIMsgMessageService::DisplayMessage ( in string  aMessageURI,
in nsISupports  aDisplayConsumer,
in nsIMsgWindow  aMsgWindow,
in nsIUrlListener  aUrlListener,
in string  aCharsetOverride,
out nsIURI  aURL 
) [inherited]

Here is the caller graph for this function:

void nsIMsgMessageService::DisplayMessageForPrinting ( in string  aMessageURI,
in nsISupports  aDisplayConsumer,
in nsIMsgWindow  aMsgWindow,
in nsIUrlListener  aUrlListener,
out nsIURI  aURL 
) [inherited]
nsresult nsMailboxService::FetchMessage ( const char *  aMessageURI,
nsISupports *  aDisplayConsumer,
nsIMsgWindow aMsgWindow,
nsIUrlListener aUrlListener,
const char *  aFileName,
nsMailboxAction  mailboxAction,
const char *  aCharsetOverride,
nsIURI **  aURL 
) [protected]

Definition at line 170 of file nsMailboxService.cpp.

{
  nsresult rv = NS_OK;
  nsCOMPtr<nsIMailboxUrl> mailboxurl;
  
  nsMailboxAction actionToUse = mailboxAction;
  
  nsCOMPtr <nsIURI> url;

  nsCAutoString uriString(aMessageURI);

  if (!strncmp(aMessageURI, "file:", 5))
  {
    PRInt64 fileSize;
    nsCOMPtr<nsIURI> fileUri;
    rv = NS_NewURI(getter_AddRefs(fileUri), aMessageURI);
    NS_ENSURE_SUCCESS(rv, rv);
    nsCOMPtr <nsIFileURL> fileUrl = do_QueryInterface(fileUri, &rv);
    NS_ENSURE_SUCCESS(rv, rv);
    nsCOMPtr <nsIFile> file;
    rv = fileUrl->GetFile(getter_AddRefs(file));
    NS_ENSURE_SUCCESS(rv, rv);
    file->GetFileSize(&fileSize);
    nsCAutoString uriString(aMessageURI);
    uriString.ReplaceSubstring(NS_LITERAL_CSTRING("file:"), NS_LITERAL_CSTRING("mailbox:"));
    uriString.Append(NS_LITERAL_CSTRING("&number=0"));
    rv = NS_NewURI(getter_AddRefs(url), uriString);
    NS_ENSURE_SUCCESS(rv, rv);

    nsCOMPtr<nsIMsgMailNewsUrl> msgurl = do_QueryInterface(url);
    if (msgurl)
    {
      msgurl->SetMsgWindow(aMsgWindow);
      nsCOMPtr <nsIMailboxUrl> mailboxUrl = do_QueryInterface(msgurl, &rv);
      mailboxUrl->SetMessageSize((PRUint32) fileSize);
      nsCOMPtr <nsIMsgHeaderSink> headerSink;
       // need to tell the header sink to capture some headers to create a fake db header
       // so we can do reply to a .eml file or a rfc822 msg attachment.
      if (aMsgWindow)
        aMsgWindow->GetMsgHeaderSink(getter_AddRefs(headerSink));
      if (headerSink)
      {
        nsCOMPtr <nsIMsgDBHdr> dummyHeader;
        headerSink->GetDummyMsgHeader(getter_AddRefs(dummyHeader));
        if (dummyHeader)
          dummyHeader->SetMessageSize((PRUint32) fileSize);
      }
    }
  }
  else
  {

    // this happens with forward inline of message/rfc822 attachment
    // opened in a stand-alone msg window.
    PRInt32 typeIndex = typeIndex = uriString.Find("&type=application/x-message-display");
    if (typeIndex != kNotFound)
    {
      uriString.Cut(typeIndex, sizeof("&type=application/x-message-display") - 1);
      rv = NS_NewURI(getter_AddRefs(url), uriString.get());
      mailboxurl = do_QueryInterface(url);
    }
    else
      rv = PrepareMessageUrl(aMessageURI, aUrlListener, actionToUse , getter_AddRefs(mailboxurl), aMsgWindow);
  
    if (NS_SUCCEEDED(rv))
    {
      url = do_QueryInterface(mailboxurl);
      nsCOMPtr<nsIMsgMailNewsUrl> msgUrl (do_QueryInterface(url));
      msgUrl->SetMsgWindow(aMsgWindow);
      nsCOMPtr<nsIMsgI18NUrl> i18nurl (do_QueryInterface(msgUrl));
      i18nurl->SetCharsetOverRide(aCharsetOverride);
      if (aFileName)
        msgUrl->SetFileName(nsDependentCString(aFileName));
    }
  }
    
  // instead of running the mailbox url like we used to, let's try to run the url in the docshell...
  nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aDisplayConsumer, &rv));
  // if we were given a docShell, run the url in the docshell..otherwise just run it normally.
  if (NS_SUCCEEDED(rv) && docShell)
  {
    nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
    // DIRTY LITTLE HACK --> if we are opening an attachment we want the docshell to
    // treat this load as if it were a user click event. Then the dispatching stuff will be much
    // happier.
    if (mailboxAction == nsIMailboxUrl::ActionFetchPart)
    {
      docShell->CreateLoadInfo(getter_AddRefs(loadInfo));
      loadInfo->SetLoadType(nsIDocShellLoadInfo::loadLink);
    }
    rv = docShell->LoadURI(url, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE, PR_FALSE);
  }
  else
    rv = RunMailboxUrl(url, aDisplayConsumer); 
 
  if (aURL && mailboxurl)
    mailboxurl->QueryInterface(NS_GET_IID(nsIURI), (void **) aURL);
  
  return rv;
}

Here is the call graph for this function:

nsIURI nsIMsgMessageFetchPartService::fetchMimePart ( in nsIURI  aURI,
in string  aMessageUri,
in nsISupports  aDisplayConsumer,
in nsIMsgWindow  aMsgWindow,
in nsIUrlListener  aUrlListener 
) [inherited]
void nsIMsgMessageService::GetUrlForUri ( in string  aMessageURI,
out nsIURI  aURL,
in nsIMsgWindow  aMsgWindow 
) [inherited]

now the the message datasource is going away we need away to go from message uri to go nsIMsgDBHdr

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.
void nsIMsgMessageService::openAttachment ( in string  aContentType,
in string  aFileName,
in string  aUrl,
in string  aMessageUri,
in nsISupports  aDisplayConsumer,
in nsIMsgWindow  aMsgWindow,
in nsIUrlListener  aUrlListener 
) [inherited]
nsIURI nsIMailboxService::ParseMailbox ( in nsIMsgWindow  aMsgWindow,
in nsFileSpec  aMailboxPath,
in nsIStreamListener  aMailboxParser,
in nsIUrlListener  aUrlListener 
) [inherited]
nsresult nsMailboxService::PrepareMessageUrl ( const char *  aSrcMsgMailboxURI,
nsIUrlListener aUrlListener,
nsMailboxAction  aMailboxAction,
nsIMailboxUrl **  aMailboxUrl,
nsIMsgWindow msgWindow 
) [protected]

Definition at line 436 of file nsMailboxService.cpp.

{
  nsresult rv = CallCreateInstance(kCMailboxUrl, aMailboxUrl);
  if (NS_SUCCEEDED(rv) && aMailboxUrl && *aMailboxUrl)
  {
    // okay now generate the url string
    char * urlSpec;
    nsCAutoString folderURI;
    nsFileSpec folderPath;
    nsMsgKey msgKey;
    const char *part = PL_strstr(aSrcMsgMailboxURI, "part=");
    const char *header = PL_strstr(aSrcMsgMailboxURI, "header=");
    rv = nsParseLocalMessageURI(aSrcMsgMailboxURI, folderURI, &msgKey);
    NS_ENSURE_SUCCESS(rv,rv);
    rv = nsLocalURI2Path(kMailboxRootURI, folderURI.get(), folderPath);
    
    if (NS_SUCCEEDED(rv))
    {
      // set up the url spec and initialize the url with it.
      nsFilePath filePath(folderPath); // convert to file url representation...
      nsCAutoString buf;
      NS_EscapeURL((const char *)filePath,-1,
                   esc_Directory|esc_Forced|esc_AlwaysCopy,buf);
      if (mPrintingOperation)
        urlSpec = PR_smprintf("mailbox://%s?number=%d&header=print", buf.get(), msgKey);
      else if (part)
        urlSpec = PR_smprintf("mailbox://%s?number=%d&%s", buf.get(), msgKey, part);
      else if (header)
        urlSpec = PR_smprintf("mailbox://%s?number=%d&%s", buf.get(), msgKey, header);
      else
        urlSpec = PR_smprintf("mailbox://%s?number=%d", buf.get(), msgKey);
      
      nsCOMPtr <nsIMsgMailNewsUrl> url = do_QueryInterface(*aMailboxUrl);
      url->SetSpec(nsDependentCString(urlSpec));
      PR_Free(urlSpec);
      
      (*aMailboxUrl)->SetMailboxAction(aMailboxAction);
      
      // set up the url listener
      if (aUrlListener)
        rv = url->RegisterListener(aUrlListener);
      
      url->SetMsgWindow(msgWindow);
      nsCOMPtr<nsIMsgMessageUrl> msgUrl = do_QueryInterface(url);
      if (msgUrl)
      {
        msgUrl->SetOriginalSpec(aSrcMsgMailboxURI);
        msgUrl->SetUri(aSrcMsgMailboxURI);
      }
      
    } // if we got a url
  } // if we got a url
  
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMailboxService::RunMailboxUrl ( nsIURI aMailboxUrl,
nsISupports *  aDisplayConsumer = nsnull 
) [protected]

Definition at line 410 of file nsMailboxService.cpp.

{
  // create a protocol instance to run the url..
  nsresult rv = NS_OK;
  nsMailboxProtocol * protocol = new nsMailboxProtocol(aMailboxUrl);
  
  if (protocol)
  {
    rv = protocol->Initialize(aMailboxUrl);
    if (NS_FAILED(rv)) 
    {
      delete protocol;
      return rv;
    }
    NS_ADDREF(protocol);
    rv = protocol->LoadUrl(aMailboxUrl, aDisplayConsumer);
    NS_RELEASE(protocol); // after loading, someone else will have a ref cnt on the mailbox
  }
              
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIMsgMessageService::SaveMessageToDisk ( in string  aMessageURI,
in nsIFileSpec  aFile,
in boolean  aGenerateDummyEnvelope,
in nsIUrlListener  aUrlListener,
out nsIURI  aURL,
in boolean  canonicalLineEnding,
in nsIMsgWindow  aMsgWindow 
) [inherited]
void nsIMsgMessageService::Search ( in nsIMsgSearchSession  aSearchSession,
in nsIMsgWindow  aMsgWindow,
in nsIMsgFolder  aMsgFolder,
in string  aSearchUri 
) [inherited]
nsIURI nsIMsgMessageService::streamMessage ( in string  aMessageURI,
in nsISupports  aConsumer,
in nsIMsgWindow  aMsgWindow,
in nsIUrlListener  aUrlListener,
in boolean  aConvertData,
in string  aAdditionalHeader 
) [inherited]

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.

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.

Definition at line 69 of file nsMailboxService.h.

readonly attribute unsigned long nsIProtocolHandler::protocolFlags [inherited]

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

Definition at line 66 of file nsIProtocolHandler.idl.

readonly attribute ACString nsIProtocolHandler::scheme [inherited]

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

Definition at line 54 of file nsIProtocolHandler.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: