Back to index

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

#include <nsSmtpUrl.h>

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

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSIURI
NS_DECL_NSIMAILTOURL 
nsMailtoUrl ()
void GetMessageContents (out string aToPart, out string aCcPart, out string aBccPart, out string aFromPart, out string aFollowUpToPart, out string aOrganizationPart, out string aReplyToPart, out string aSubjectPart, out string aBodyPart, out string aHtmlPart, out string aReferencePart, out string aAttachmentPart, out string aPriorityPart, out string aNewsgroupPart, out string aNewsHostPart, out MSG_ComposeFormat aFormat)
boolean equals (in nsIURI other)
 URI equivalence test (not a strict string comparison).
boolean schemeIs (in string scheme)
 An optimization to do scheme checks without requiring the users of nsIURI to GetScheme, thereby saving extra allocating and freeing.
nsIURI clone ()
 Clones the current URI.
AUTF8String resolve (in AUTF8String relativePath)
 This method resolves a relative string into an absolute URI string, using this URI as the base.

Public Attributes

attribute AUTF8String spec
 Returns a string representation of the URI.
readonly attribute AUTF8String prePath
 The prePath (eg.
attribute ACString scheme
 The Scheme is the protocol to which this URI refers.
attribute AUTF8String userPass
 The username:password (or username only if value doesn't contain a ':')
attribute AUTF8String username
 The optional username and password, assuming the preHost consists of username:password.
attribute AUTF8String password
attribute AUTF8String hostPort
 The host:port (or simply the host, if port == -1).
attribute AUTF8String host
 The host is the internet domain name to which this URI refers.
attribute long port
 A port value of -1 corresponds to the protocol's default port (eg.
attribute AUTF8String path
 The path, typically including at least a leading '/' (but may also be empty, depending on the protocol).
readonly attribute ACString asciiSpec
 The URI spec with an ASCII compatible encoding.
readonly attribute ACString asciiHost
 The URI host with an ASCII compatible encoding.
readonly attribute ACString originCharset
 The charset of the document from which this URI originated.

Protected Member Functions

virtual ~nsMailtoUrl ()
nsresult ParseUrl ()
nsresult CleanupMailtoState ()
nsresult ParseMailtoUrl (char *searchPart)

Protected Attributes

nsCOMPtr< nsIURIm_baseURL
nsCString m_toPart
nsCString m_ccPart
nsCString m_subjectPart
nsCString m_newsgroupPart
nsCString m_newsHostPart
nsCString m_referencePart
nsCString m_bodyPart
nsCString m_bccPart
nsCString m_followUpToPart
nsCString m_fromPart
nsCString m_htmlPart
nsCString m_organizationPart
nsCString m_replyToPart
nsCString m_priorityPart
MSG_ComposeFormat mFormat

Detailed Description

Definition at line 53 of file nsSmtpUrl.h.


Constructor & Destructor Documentation

Definition at line 56 of file nsSmtpUrl.cpp.

Here is the call graph for this function:

nsMailtoUrl::~nsMailtoUrl ( ) [protected, virtual]

Definition at line 62 of file nsSmtpUrl.cpp.

{
}

Member Function Documentation

Definition at line 289 of file nsSmtpUrl.cpp.

nsIURI nsIURI::clone ( ) [inherited]

Clones the current URI.

For some protocols, this is more than just an optimization. For example, under MacOS, the spec of a file URL does not necessarily uniquely identify a file since two volumes could share the same name.

Here is the caller graph for this function:

boolean nsIURI::equals ( in nsIURI  other) [inherited]

URI equivalence test (not a strict string comparison).

eg. http://foo.com:80/ == http://foo.com/

void nsIMailtoUrl::GetMessageContents ( out string  aToPart,
out string  aCcPart,
out string  aBccPart,
out string  aFromPart,
out string  aFollowUpToPart,
out string  aOrganizationPart,
out string  aReplyToPart,
out string  aSubjectPart,
out string  aBodyPart,
out string  aHtmlPart,
out string  aReferencePart,
out string  aAttachmentPart,
out string  aPriorityPart,
out string  aNewsgroupPart,
out string  aNewsHostPart,
out MSG_ComposeFormat  aFormat 
) [inherited]
nsresult nsMailtoUrl::ParseMailtoUrl ( char *  searchPart) [protected]

Definition at line 68 of file nsSmtpUrl.cpp.

{
       char *rest = searchPart;
        nsCAutoString inReplyToPart;
       // okay, first, free up all of our old search part state.....
       CleanupMailtoState();

       if (rest && *rest == '?')
       {
              /* start past the '?' */
              rest++;
       }

       if (rest)
       {
    char *token = nsCRT::strtok(rest, "&", &rest);
              while (token && *token)
              {
                     char *value = 0;
      char *eq = PL_strchr(token, '=');
                     if (eq)
                     {
                            value = eq+1;
                            *eq = 0;
                     }
                     
                     switch (nsCRT::ToUpper(*token))
                     {
/* DO NOT support attachment= in mailto urls. This poses a security fire hole!!! 
                            case 'A':
          if (!nsCRT::strcasecmp (token, "attachment"))
                                     m_attachmentPart = value;
                              break;
*/
                            case 'B':
                              if (!nsCRT::strcasecmp (token, "bcc"))
                              {
                                     if (!m_bccPart.IsEmpty())
            {
               m_bccPart += ", ";
               m_bccPart += value;
            }
            else
                                       m_bccPart = value; 
          }
                                   else if (!nsCRT::strcasecmp (token, "body"))
                                   {
            if (!m_bodyPart.IsEmpty())
            {
              m_bodyPart +="\n";
              m_bodyPart += value;
            }
            else
              m_bodyPart = value;
          }
          break;
        case 'C': 
                                   if (!nsCRT::strcasecmp  (token, "cc"))
                                   {
                                          if (!m_ccPart.IsEmpty())
                                          {
              m_ccPart += ", ";
              m_ccPart += value;
                                          }
                                          else
                                                 m_ccPart = value;
                                   }
          break;
        case 'F': 
                                   if (!nsCRT::strcasecmp (token, "followup-to"))
                                          m_followUpToPart = value;
                                   else if (!nsCRT::strcasecmp (token, "from"))
                                          m_fromPart = value;
                                   break;
        case 'H':
          if (!nsCRT::strcasecmp(token, "html-part") || !nsCRT::strcasecmp (token, "html-body"))
          {
            // m_htmlPart holds the body for both html-part and html-body.
            m_htmlPart = value;
            mFormat = nsIMsgCompFormat::HTML;
          }
          break;
                                case 'I':
                                        if (!nsCRT::strcasecmp (token, "in-reply-to"))
                                                inReplyToPart = value;
                                        break;

                            case 'N':
                                   if (!nsCRT::strcasecmp (token, "newsgroups"))
                                          m_newsgroupPart = value;
                                   else if (!nsCRT::strcasecmp (token, "newshost"))
                                          m_newsHostPart = value;
                              break;
                            case 'O':
                                   if (!nsCRT::strcasecmp (token, "organization"))
                                          m_organizationPart = value;
                                   break;
        case 'R':
                                   if (!nsCRT::strcasecmp (token, "references"))
                                          m_referencePart = value;
                                   else if (!nsCRT::strcasecmp (token, "reply-to"))
                                          m_replyToPart = value;
                                   break;
                            case 'S':
                                   if(!nsCRT::strcasecmp (token, "subject"))
                                          m_subjectPart = value;
                                   break;
                            case 'P':
                                   if (!nsCRT::strcasecmp (token, "priority"))
                                          m_priorityPart = PL_strdup(value);
                                   break;
                            case 'T':
                                   if (!nsCRT::strcasecmp (token, "to"))
                              {
                                          if (!m_toPart.IsEmpty())
                                          {
              m_toPart += ", ";
              m_toPart += value;
                                          }
                                          else
                                                 m_toPart = value;
                                   }
                                   break;
        default:
          break;
      } // end of switch statement...
                     
                     if (eq)
                              *eq = '='; /* put it back */
                            token = nsCRT::strtok(rest, "&", &rest);
              } // while we still have part of the url to parse...
       } // if rest && *rest

  // Ensure that References and In-Reply-To are consistent...
  if (!inReplyToPart.IsEmpty())
  {
    if (m_referencePart.IsEmpty())
      m_referencePart = inReplyToPart;
    else
    {
      const char * lastRef = strrchr(m_referencePart.get(), '<');
      nsCAutoString lastReference;
      lastReference = lastRef ? lastRef : m_referencePart.get();
      if (lastReference != inReplyToPart)
      {
        m_referencePart += " ";
        m_referencePart += inReplyToPart;
      }
    }
  }

  nsCOMPtr<nsIMimeConverter> mimeConverter = do_GetService(NS_MIME_CONVERTER_CONTRACTID);
  char *decodedString;

  // Now unescape any fields that need escaped...
       if (!m_toPart.IsEmpty())
  {
              nsUnescape(m_toPart.BeginWriting());
    if (mimeConverter)
    {
      if (NS_SUCCEEDED(mimeConverter->DecodeMimeHeader(m_toPart.get(),
                                                       &decodedString,
                                                       "UTF-8", PR_FALSE))
                                                       && decodedString)
        m_toPart.Adopt(decodedString);
    }
  }
       if (!m_ccPart.IsEmpty())
  {
              nsUnescape(m_ccPart.BeginWriting());
    if (mimeConverter)
    {
      if (NS_SUCCEEDED(mimeConverter->DecodeMimeHeader(m_ccPart.get(),
                                                       &decodedString,
                                                       "UTF-8", PR_FALSE))
                                                       && decodedString)
        m_ccPart.Adopt(decodedString);
    }
  }
       if (!m_subjectPart.IsEmpty())
  {
    nsUnescape(m_subjectPart.BeginWriting());
    if (mimeConverter)
    {
      if (NS_SUCCEEDED(mimeConverter->DecodeMimeHeader(m_subjectPart.get(),
                                                       &decodedString,
                                                       "UTF-8", PR_FALSE))
                                                       && decodedString)
        m_subjectPart.Adopt(decodedString);
    }
  }
       if (!m_newsgroupPart.IsEmpty())
              nsUnescape(m_newsgroupPart.BeginWriting());
       if (!m_referencePart.IsEmpty())
              nsUnescape(m_referencePart.BeginWriting());
       if (!m_bodyPart.IsEmpty())
  {
              nsUnescape(m_bodyPart.BeginWriting());
    if (mimeConverter)
    {
      if (NS_SUCCEEDED(mimeConverter->DecodeMimeHeader(m_bodyPart.get(),
                                                       &decodedString,
                                                       "UTF-8", PR_FALSE,
                                                       PR_FALSE))
                                                       && decodedString)
        m_bodyPart.Adopt(decodedString);
    }
  }
       if (!m_newsHostPart.IsEmpty())
              nsUnescape(m_newsHostPart.BeginWriting());

       return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 307 of file nsSmtpUrl.cpp.

{
       nsresult rv = NS_OK;

  // we can get the path from the simple url.....
  nsCAutoString aPath;
  m_baseURL->GetPath(aPath);
  m_toPart.Assign(aPath);

  PRInt32 startOfSearchPart = m_toPart.FindChar('?');
  if (startOfSearchPart >= 0)
  {
    // now parse out the search field...
    nsCAutoString searchPart;
    PRUint32 numExtraChars = m_toPart.Right(searchPart,
                                            m_toPart.Length() -
                                            startOfSearchPart);
    if (!searchPart.IsEmpty())
    {
      // now we need to strip off the search part from the
      // to part....
      m_toPart.Cut(startOfSearchPart, numExtraChars);
      ParseMailtoUrl(searchPart.BeginWriting());
    }
       }
  else if (!m_toPart.IsEmpty())
  {
    nsUnescape(m_toPart.BeginWriting());
  }

  return rv;
}

Here is the call graph for this function:

AUTF8String nsIURI::resolve ( in AUTF8String  relativePath) [inherited]

This method resolves a relative string into an absolute URI string, using this URI as the base.

NOTE: some implementations may have no concept of a relative URI.

boolean nsIURI::schemeIs ( in string  scheme) [inherited]

An optimization to do scheme checks without requiring the users of nsIURI to GetScheme, thereby saving extra allocating and freeing.

Returns true if the schemes match (case ignored).


Member Data Documentation

readonly attribute ACString nsIURI::asciiHost [inherited]

The URI host with an ASCII compatible encoding.

Follows the IDNA draft spec for converting internationalized domain names (UTF-8) to ASCII for compatibility with existing internet infrasture.

Definition at line 220 of file nsIURI.idl.

readonly attribute ACString nsIURI::asciiSpec [inherited]

The URI spec with an ASCII compatible encoding.

Host portion follows the IDNA draft spec. Other parts are URL-escaped per the rules of RFC2396. The result is strictly ASCII.

Definition at line 213 of file nsIURI.idl.

attribute AUTF8String nsIURI::host [inherited]

The host is the internet domain name to which this URI refers.

It could be an IPv4 (or IPv6) address literal. If supported, it could be a non-ASCII internationalized domain name.

Characters are NOT escaped.

Definition at line 152 of file nsIURI.idl.

attribute AUTF8String nsIURI::hostPort [inherited]

The host:port (or simply the host, if port == -1).

Characters are NOT escaped.

Definition at line 143 of file nsIURI.idl.

Definition at line 68 of file nsSmtpUrl.h.

Definition at line 78 of file nsSmtpUrl.h.

Definition at line 77 of file nsSmtpUrl.h.

Definition at line 72 of file nsSmtpUrl.h.

Definition at line 79 of file nsSmtpUrl.h.

Definition at line 80 of file nsSmtpUrl.h.

Definition at line 81 of file nsSmtpUrl.h.

Definition at line 74 of file nsSmtpUrl.h.

Definition at line 75 of file nsSmtpUrl.h.

Definition at line 82 of file nsSmtpUrl.h.

Definition at line 84 of file nsSmtpUrl.h.

Definition at line 76 of file nsSmtpUrl.h.

Definition at line 83 of file nsSmtpUrl.h.

Definition at line 73 of file nsSmtpUrl.h.

Definition at line 71 of file nsSmtpUrl.h.

Definition at line 86 of file nsSmtpUrl.h.

readonly attribute ACString nsIURI::originCharset [inherited]

The charset of the document from which this URI originated.

An empty value implies UTF-8.

If this value is something other than UTF-8 then the URI components (e.g., spec, prePath, username, etc.) will all be fully URL-escaped. Otherwise, the URI components may contain unescaped multibyte UTF-8 characters.

Definition at line 231 of file nsIURI.idl.

attribute AUTF8String nsIURI::password [inherited]

Definition at line 136 of file nsIURI.idl.

attribute AUTF8String nsIURI::path [inherited]

The path, typically including at least a leading '/' (but may also be empty, depending on the protocol).

Some characters may be escaped.

Definition at line 166 of file nsIURI.idl.

A port value of -1 corresponds to the protocol's default port (eg.

-1 implies port 80 for http URIs).

Definition at line 158 of file nsIURI.idl.

readonly attribute AUTF8String nsIURI::prePath [inherited]

The prePath (eg.

scheme://user:password:port) returns the string before the path. This is useful for authentication or managing sessions.

Some characters may be escaped.

Definition at line 114 of file nsIURI.idl.

attribute ACString nsIURI::scheme [inherited]

The Scheme is the protocol to which this URI refers.

The scheme is restricted to the US-ASCII charset per RFC2396.

Definition at line 120 of file nsIURI.idl.

attribute AUTF8String nsIURI::spec [inherited]

Returns a string representation of the URI.

Setting the spec causes the new spec to be parsed, initializing the URI.

Some characters may be escaped.

Definition at line 106 of file nsIURI.idl.

attribute AUTF8String nsIURI::username [inherited]

The optional username and password, assuming the preHost consists of username:password.

Some characters may be escaped.

Definition at line 135 of file nsIURI.idl.

attribute AUTF8String nsIURI::userPass [inherited]

The username:password (or username only if value doesn't contain a ':')

Some characters may be escaped.

Definition at line 127 of file nsIURI.idl.


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