Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes
nsMsgSearchOnlineMail Class Reference

#include <nsMsgSearchImap.h>

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

List of all members.

Public Member Functions

 nsMsgSearchOnlineMail (nsMsgSearchScopeTerm *scope, nsISupportsArray *termList)
virtual ~nsMsgSearchOnlineMail ()
NS_IMETHOD ValidateTerms ()
NS_IMETHOD Search (PRBool *aDone)
NS_IMETHOD GetEncoding (char **result)
NS_IMETHOD AddResultElement (nsIMsgDBHdr *)
void Search (out boolean done)
void SendUrl ()
void CurrentUrlDone (in long exitCode)
void AddHit (in nsMsgKey key)
void AddResultElement (in nsIMsgDBHdr aHdr)
void OpenResultElement (in nsMsgResultElement element)
void ModifyResultElement (in nsMsgResultElement element, in nsMsgSearchValue value)
nsIMsgFolder FindTargetFolder ([const ] in nsMsgResultElement element)
void Abort ()
void getSearchCharsets (out wstring srcCharset, out wstring destCharset)

Static Public Member Functions

static nsresult Encode (nsCString &ppEncoding, nsISupportsArray *searchTerms, const PRUnichar *destCharset)
static nsresult EncodeImap (char **ppEncoding, nsISupportsArray *searchTerms, const PRUnichar *srcCharset, const PRUnichar *destCharset, PRBool reallyDredd=PR_FALSE)
static nsresult EncodeImapValue (char *encoding, const char *value, PRBool useQuotes, PRBool reallyDredd)
static char * GetImapCharsetParam (const PRUnichar *destCharset)
static PRUnicharEscapeSearchUrl (const PRUnichar *nntpCommand)
static PRUnicharEscapeImapSearchProtocol (const PRUnichar *imapCommand)
static PRUnicharEscapeQuoteImapSearchProtocol (const PRUnichar *imapCommand)
static char * UnEscapeSearchUrl (const char *commandSpecificData)

Public Attributes

NS_DECL_ISUPPORTS
NS_DECL_NSIMSGSEARCHADAPTER
nsIMsgSearchScopeTerm
m_scope
nsCOMPtr< nsISupportsArraym_searchTerms
PRBool m_abortCalled
nsXPIDLString m_defaultCharset
PRBool m_forceAsciiSearch
readonly attribute string encoding

Static Public Attributes

static const char * m_kImapBefore = " SENTBEFORE "
static const char * m_kImapBody = " BODY "
static const char * m_kImapCC = " CC "
static const char * m_kImapFrom = " FROM "
static const char * m_kImapNot = " NOT"
static const char * m_kImapOr = " OR"
static const char * m_kImapSince = " SENTSINCE "
static const char * m_kImapSubject = " SUBJECT "
static const char * m_kImapTo = " TO "
static const char * m_kImapHeader = " HEADER"
static const char * m_kImapAnyText = " TEXT "
static const char * m_kImapKeyword = " KEYWORD "
static const char * m_kNntpKeywords = " KEYWORDS "
static const char * m_kImapSentOn = " SENTON "
static const char * m_kImapSeen = " SEEN "
static const char * m_kImapAnswered = " ANSWERED "
static const char * m_kImapNotSeen = " UNSEEN "
static const char * m_kImapNotAnswered = " UNANSWERED "
static const char * m_kImapCharset = " CHARSET "
static const char * m_kImapUnDeleted = " UNDELETED"
static const char * m_kImapSizeSmaller = " SMALLER "
static const char * m_kImapSizeLarger = " LARGER "
static const char * m_kImapNew = " NEW "
static const char * m_kImapNotNew = " OLD SEEN "
static const char * m_kImapFlagged = " FLAGGED "
static const char * m_kImapNotFlagged = " UNFLAGGED "

Protected Types

enum  _msg_TransformType { kOverwrite, kInsert, kSurround }
typedef enum
nsMsgSearchAdapter::_msg_TransformType 
msg_TransformType

Protected Member Functions

char * TransformSpacesToStars (const char *, msg_TransformType transformType)
nsresult OpenNewsResultInUnknownGroup (nsMsgResultElement *)

Static Protected Member Functions

static nsresult EncodeImapTerm (nsIMsgSearchTerm *, PRBool reallyDredd, const PRUnichar *srcCharset, const PRUnichar *destCharset, char **ppOutTerm)

Protected Attributes

nsCString m_encoding

Detailed Description

Definition at line 45 of file nsMsgSearchImap.h.


Member Typedef Documentation


Member Enumeration Documentation

enum nsMsgSearchAdapter::_msg_TransformType [protected, inherited]
Enumerator:
kOverwrite 
kInsert 
kSurround 

Definition at line 127 of file nsMsgSearchAdapter.h.

  {
         kOverwrite,    /* "John Doe" -> "John*Doe",   simple contains   */
         kInsert,       /* "John Doe" -> "John* Doe",  name completion   */
         kSurround      /* "John Doe" -> "John* *Doe", advanced contains */
  } msg_TransformType;

Constructor & Destructor Documentation

Definition at line 49 of file nsMsgImapSearch.cpp.

                                                                                                     : nsMsgSearchAdapter (scope, termList)
{
}

Definition at line 54 of file nsMsgImapSearch.cpp.

{
}

Member Function Documentation

Implemented in nsMsgSearchOfflineMail.

Definition at line 85 of file nsMsgImapSearch.cpp.

{
    nsresult err = NS_OK;

    nsCOMPtr<nsIMsgSearchSession> searchSession;
    m_scope->GetSearchSession(getter_AddRefs(searchSession));
    if (searchSession)
    {
      nsCOMPtr <nsIMsgFolder> scopeFolder;
      err = m_scope->GetFolder(getter_AddRefs(scopeFolder));
      searchSession->AddSearchHit(pHeaders, scopeFolder);
    }
    //XXXX alecf do not checkin without fixing!        m_scope->m_searchSession->AddResultElement (newResult);
    return err;
}

Here is the call graph for this function:

void nsIMsgSearchAdapter::CurrentUrlDone ( in long  exitCode) [inherited]
nsresult nsMsgSearchOnlineMail::Encode ( nsCString ppEncoding,
nsISupportsArray searchTerms,
const PRUnichar destCharset 
) [static]

Definition at line 110 of file nsMsgImapSearch.cpp.

{
  nsXPIDLCString imapTerms;
  
  //check if searchTerms are ascii only
  PRBool asciiOnly = PR_TRUE;
  // ### what's this mean in the NWO?????
  
  if (PR_TRUE) // !(srcCharset & CODESET_MASK == STATEFUL || srcCharset & CODESET_MASK == WIDECHAR) )   //assume all single/multiple bytes charset has ascii as subset
  {
    PRUint32 termCount;
    searchTerms->Count(&termCount);
    PRUint32 i = 0;
    
    for (i = 0; i < termCount && asciiOnly; i++)
    {
      nsCOMPtr<nsIMsgSearchTerm> pTerm;
      searchTerms->QueryElementAt(i, NS_GET_IID(nsIMsgSearchTerm),
        (void **)getter_AddRefs(pTerm));
      
      nsMsgSearchAttribValue attribute;
      pTerm->GetAttrib(&attribute);
      if (IsStringAttribute(attribute))
      {
        nsXPIDLString pchar;
        nsCOMPtr <nsIMsgSearchValue> searchValue;
        
        nsresult rv = pTerm->GetValue(getter_AddRefs(searchValue));
        if (NS_FAILED(rv) || !searchValue)
          continue;
        
        
        rv = searchValue->GetStr(getter_Copies(pchar));
        if (NS_FAILED(rv) || !pchar)
          continue;
        asciiOnly = nsCRT::IsAscii(pchar.get());
      }
    }
  }
  else
    asciiOnly = PR_FALSE;
  
  nsAutoString usAsciiCharSet(NS_LITERAL_STRING("us-ascii"));
  // Get the optional CHARSET parameter, in case we need it.
  char *csname = GetImapCharsetParam(asciiOnly ? usAsciiCharSet.get() : destCharset);
  
  // We do not need "srcCharset" since the search term in always unicode.
  // I just pass destCharset for both src and dest charset instead of removing srcCharst from the arguemnt.
  nsresult err = nsMsgSearchAdapter::EncodeImap (getter_Copies(imapTerms), searchTerms, 
    asciiOnly ?  usAsciiCharSet.get(): destCharset, 
    asciiOnly ?  usAsciiCharSet.get(): destCharset, PR_FALSE);
  if (NS_SUCCEEDED(err))
  {
    pEncoding.Append("SEARCH");
    if (csname)
      pEncoding.Append(csname);
    pEncoding.Append(imapTerms);
  }
  PR_FREEIF(csname);
  return err;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgSearchAdapter::EncodeImap ( char **  ppEncoding,
nsISupportsArray searchTerms,
const PRUnichar srcCharset,
const PRUnichar destCharset,
PRBool  reallyDredd = PR_FALSE 
) [static, inherited]

Definition at line 765 of file nsMsgSearchAdapter.cpp.

{
  // i've left the old code (before using CBoolExpression for debugging purposes to make sure that
  // the new code generates the same encoding string as the old code.....
  
  nsresult err = NS_OK;
  *ppOutEncoding = nsnull;
  
  PRUint32 termCount;
  searchTerms->Count(&termCount);
  PRUint32 i = 0;
  
  // create our expression
  nsMsgSearchBoolExpression * expression = new nsMsgSearchBoolExpression();
  if (!expression)
    return NS_ERROR_OUT_OF_MEMORY;
  
  for (i = 0; i < termCount && NS_SUCCEEDED(err); i++)
  {
    char *termEncoding;
    nsCOMPtr<nsIMsgSearchTerm> pTerm;
    searchTerms->QueryElementAt(i, NS_GET_IID(nsIMsgSearchTerm),
      (void **)getter_AddRefs(pTerm));
    err = EncodeImapTerm (pTerm, reallyDredd, srcCharset, destCharset, &termEncoding);
    if (NS_SUCCEEDED(err) && nsnull != termEncoding)
    {
      expression = nsMsgSearchBoolExpression::AddSearchTerm(expression, pTerm, termEncoding);
      delete [] termEncoding;
    }
  }
  
  if (NS_SUCCEEDED(err)) 
  {
    // Catenate the intermediate encodings together into a big string
    nsCAutoString encodingBuff;
    
    if (!reallyDredd)
      encodingBuff.Append(m_kImapUnDeleted);

    expression->GenerateEncodeStr(&encodingBuff);
    *ppOutEncoding = ToNewCString(encodingBuff);
  }
  
  delete expression;
  
  return err;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgSearchAdapter::EncodeImapTerm ( nsIMsgSearchTerm term,
PRBool  reallyDredd,
const PRUnichar srcCharset,
const PRUnichar destCharset,
char **  ppOutTerm 
) [static, protected, inherited]

Definition at line 401 of file nsMsgSearchAdapter.cpp.

{
  nsresult err = NS_OK;
  PRBool useNot = PR_FALSE;
  PRBool useQuotes = PR_FALSE;
  PRBool ignoreValue = PR_FALSE;
  nsCAutoString arbitraryHeader;
  const char *whichMnemonic = nsnull;
  const char *orHeaderMnemonic = nsnull;
  
  *ppOutTerm = nsnull;
  
  nsCOMPtr <nsIMsgSearchValue> searchValue;
  nsresult rv = term->GetValue(getter_AddRefs(searchValue));
  
  if (NS_FAILED(rv))
    return rv;
  
  nsMsgSearchOpValue op;
  term->GetOp(&op);
  
  if (op == nsMsgSearchOp::DoesntContain || op == nsMsgSearchOp::Isnt)
    useNot = PR_TRUE;
  
  nsMsgSearchAttribValue attrib;
  term->GetAttrib(&attrib);
  
  switch (attrib)
  {
  case nsMsgSearchAttrib::ToOrCC:
    orHeaderMnemonic = m_kImapCC;
    // fall through to case nsMsgSearchAttrib::To:
  case nsMsgSearchAttrib::To:
    whichMnemonic = m_kImapTo;
    break;
  case nsMsgSearchAttrib::CC:
    whichMnemonic = m_kImapCC;
    break;
  case nsMsgSearchAttrib::Sender:
    whichMnemonic = m_kImapFrom;
    break;
  case nsMsgSearchAttrib::Subject:
    whichMnemonic = m_kImapSubject;
    break;
  case nsMsgSearchAttrib::Body:
    whichMnemonic = m_kImapBody;
    break;
  case nsMsgSearchAttrib::AgeInDays:  // added for searching online for age in days...
    // for AgeInDays, we are actually going to perform a search by date, so convert the operations for age
    // to the IMAP mnemonics that we would use for date!
    switch (op)
    {
    case nsMsgSearchOp::IsGreaterThan:
      whichMnemonic = m_kImapBefore;
      break;
    case nsMsgSearchOp::IsLessThan:
      whichMnemonic = m_kImapSince;
      break;
    case nsMsgSearchOp::Is:
      whichMnemonic = m_kImapSentOn;
      break;
    default:
      NS_ASSERTION(PR_FALSE, "invalid search operator");
      return NS_ERROR_INVALID_ARG;
    }
    break;
  case nsMsgSearchAttrib::Size:
    switch (op)
    {
    case nsMsgSearchOp::IsGreaterThan:
      whichMnemonic = m_kImapSizeLarger;
      break;
    case nsMsgSearchOp::IsLessThan:
      whichMnemonic = m_kImapSizeSmaller;
      break;
    default:
      NS_ASSERTION(PR_FALSE, "invalid search operator");
      return NS_ERROR_INVALID_ARG;
    }
    break;
    case nsMsgSearchAttrib::Date:
      switch (op)
      {
      case nsMsgSearchOp::IsBefore:
        whichMnemonic = m_kImapBefore;
        break;
      case nsMsgSearchOp::IsAfter:
        whichMnemonic = m_kImapSince;
        break;
      case nsMsgSearchOp::Isnt:  /* we've already added the "Not" so just process it like it was a date is search */
      case nsMsgSearchOp::Is:
        whichMnemonic = m_kImapSentOn;
        break;
      default:
        NS_ASSERTION(PR_FALSE, "invalid search operator");
        return NS_ERROR_INVALID_ARG;
      }
      break;
      case nsMsgSearchAttrib::AnyText:
        whichMnemonic = m_kImapAnyText;
        break;
      case nsMsgSearchAttrib::Keywords:
        whichMnemonic = m_kImapKeyword;
        break;
      case nsMsgSearchAttrib::MsgStatus:
        useNot = PR_FALSE; // bizarrely, NOT SEEN is wrong, but UNSEEN is right.
        ignoreValue = PR_TRUE; // the mnemonic is all we need
        PRUint32 status;
        searchValue->GetStatus(&status);
        
        switch (status)
        {
        case MSG_FLAG_READ:
          whichMnemonic = op == nsMsgSearchOp::Is ? m_kImapSeen : m_kImapNotSeen;
          break;
        case MSG_FLAG_REPLIED:
          whichMnemonic = op == nsMsgSearchOp::Is ? m_kImapAnswered : m_kImapNotAnswered;
          break;
        case MSG_FLAG_NEW:                         
          whichMnemonic = op == nsMsgSearchOp::Is ? m_kImapNew : m_kImapNotNew;
          break; 
        case MSG_FLAG_MARKED:
          whichMnemonic = op == nsMsgSearchOp::Is ? m_kImapFlagged : m_kImapNotFlagged;
          break;
        default:
          NS_ASSERTION(PR_FALSE, "invalid search operator");
          return NS_ERROR_INVALID_ARG;
        }
        break;
        default:
          if ( attrib > nsMsgSearchAttrib::OtherHeader && attrib < nsMsgSearchAttrib::kNumMsgSearchAttributes)
          {
            nsXPIDLCString arbitraryHeaderTerm;
            term->GetArbitraryHeader(getter_Copies(arbitraryHeaderTerm));
            if (!arbitraryHeaderTerm.IsEmpty())
            {
              arbitraryHeader.AssignLiteral(" \"");
              arbitraryHeader.Append(arbitraryHeaderTerm);
              arbitraryHeader.AppendLiteral("\" ");
              whichMnemonic = arbitraryHeader.get();
            }
            else
              return NS_ERROR_FAILURE;
          }
          else
          {
            NS_ASSERTION(PR_FALSE, "invalid search operator");
            return NS_ERROR_INVALID_ARG;
          }
        }
        
        char *value = "";
        char dateBuf[100];
        dateBuf[0] = '\0';
        
        PRBool valueWasAllocated = PR_FALSE;
        if (attrib == nsMsgSearchAttrib::Date)
        {
          // note that there used to be code here that encoded an RFC822 date for imap searches.
          // The IMAP RFC 2060 is misleading to the point that it looks like it requires an RFC822
          // date but really it expects dd-mmm-yyyy, like dredd, and refers to the RFC822 date only in that the
          // dd-mmm-yyyy date will match the RFC822 date within the message.
          
          PRTime adjustedDate;
          searchValue->GetDate(&adjustedDate);
          if (whichMnemonic == m_kImapSince)
          {
            // it looks like the IMAP server searches on Since includes the date in question...
            // our UI presents Is, IsGreater and IsLessThan. For the IsGreater case (m_kImapSince)
            // we need to adjust the date so we get greater than and not greater than or equal to which
            // is what the IMAP server wants to search on
            // won't work on Mac.
            // ack, is this right? is PRTime seconds or microseconds?
            PRInt64 microSecondsPerSecond, secondsInDay, microSecondsInDay;
            
            LL_I2L(microSecondsPerSecond, PR_USEC_PER_SEC);
            LL_UI2L(secondsInDay, 60 * 60 * 24);
            LL_MUL(microSecondsInDay, secondsInDay, microSecondsPerSecond);
            LL_ADD(adjustedDate, adjustedDate, microSecondsInDay); // bump up to the day after this one...
          }
          
          PRExplodedTime exploded;
          PR_ExplodeTime(adjustedDate, PR_LocalTimeParameters, &exploded);
          PR_FormatTimeUSEnglish(dateBuf, sizeof(dateBuf), "%d-%b-%Y", &exploded);
          //         strftime (dateBuf, sizeof(dateBuf), "%d-%b-%Y", localtime (/* &term->m_value.u.date */ &adjustedDate));
          value = dateBuf;
        }
        else
        {
          if (attrib == nsMsgSearchAttrib::AgeInDays)
          {
            // okay, take the current date, subtract off the age in days, then do an appropriate Date search on 
            // the resulting day.
            PRUint32 ageInDays;
            
            searchValue->GetAge(&ageInDays);
            
            PRTime now = PR_Now();
            PRTime matchDay;
            
            PRInt64 microSecondsPerSecond, secondsInDays, microSecondsInDay;
            
            LL_I2L(microSecondsPerSecond, PR_USEC_PER_SEC);
            LL_UI2L(secondsInDays, 60 * 60 * 24 * ageInDays);
            LL_MUL(microSecondsInDay, secondsInDays, microSecondsPerSecond);
            
            LL_SUB(matchDay, now, microSecondsInDay); // = now - term->m_value.u.age * 60 * 60 * 24; 
            PRExplodedTime exploded;
            PR_ExplodeTime(matchDay, PR_LocalTimeParameters, &exploded);
            PR_FormatTimeUSEnglish(dateBuf, sizeof(dateBuf), "%d-%b-%Y", &exploded);
            //                     strftime (dateBuf, sizeof(dateBuf), "%d-%b-%Y", localtime (&matchDay));
            value = dateBuf;
          }
          else if (attrib == nsMsgSearchAttrib::Size)
          {
            PRUint32 sizeValue;
            nsCAutoString searchTermValue;
            searchValue->GetSize(&sizeValue);

            // Multiply by 1024 to get into kb resolution
            sizeValue *= 1024;

            // Ensure that greater than is really greater than
            // in kb resolution.
            if (op == nsMsgSearchOp::IsGreaterThan)
              sizeValue += 1024;

            searchTermValue.AppendInt(sizeValue);

            value = nsCRT::strdup(searchTermValue.get());
            valueWasAllocated = PR_TRUE;
          }
          else
            
            if (IsStringAttribute(attrib))
            {
              PRUnichar *convertedValue; // = reallyDredd ? MSG_EscapeSearchUrl (term->m_value.u.string) : msg_EscapeImapSearchProtocol(term->m_value.u.string);
              nsXPIDLString searchTermValue;
              searchValue->GetStr(getter_Copies(searchTermValue));
              // Ugly switch for Korean mail/news charsets.
              // We want to do this here because here is where
              // we know what charset we want to use.
#ifdef DOING_CHARSET
              if (reallyDredd)
                dest_csid = INTL_DefaultNewsCharSetID(dest_csid);
              else
                dest_csid = INTL_DefaultMailCharSetID(dest_csid);
#endif
              
              // do all sorts of crazy escaping
              convertedValue = reallyDredd ? EscapeSearchUrl (searchTermValue) :
              EscapeImapSearchProtocol(searchTermValue);
              useQuotes = ((!reallyDredd || 
                          (nsDependentString(convertedValue).FindChar(PRUnichar(' ')) != -1)) &&
                 (attrib != nsMsgSearchAttrib::Keywords));
              // now convert to char* and escape quoted_specials
              nsCAutoString valueStr;
              nsresult rv = ConvertFromUnicode(NS_LossyConvertUTF16toASCII(destCharset).get(),
                nsDependentString(convertedValue), valueStr);
              if (NS_SUCCEEDED(rv))
              {
                const char *vptr = valueStr.get();
                // max escaped length is one extra character for every character in the cmd.
                nsAutoArrayPtr<char> newValue(new char[2*strlen(vptr) + 1]);
                if (newValue)
                {
                  char *p = newValue;
                  while (1)
                  {
                    char ch = *vptr++;
                    if (!ch)
                      break;
                    if ((useQuotes ? ch == '"' : 0) || ch == '\\')
                      *p++ = '\\';
                    *p++ = ch;
                  }
                  *p = '\0';
                  value = nsCRT::strdup(newValue); // realloc down to smaller size
                }
              }
              else
                value = nsCRT::strdup("");
              nsCRT::free(convertedValue);
              valueWasAllocated = PR_TRUE;
              
            }
        }
        
        // this should be rewritten to use nsCString
        int len = strlen(whichMnemonic) + strlen(value) + (useNot ? strlen(m_kImapNot) : 0) + 
          (useQuotes ? 2 : 0) + strlen(m_kImapHeader) + 
          (orHeaderMnemonic ? (strlen(m_kImapHeader) + strlen(m_kImapOr) + (useNot ? strlen(m_kImapNot) : 0) + 
          strlen(orHeaderMnemonic) + strlen(value) + 2 /*""*/) : 0) + 10; // add slough for imap string literals
        char *encoding = new char[len];
        if (encoding)
        {
          encoding[0] = '\0';
          // Remember: if ToOrCC and useNot then the expression becomes NOT To AND Not CC as opposed to (NOT TO) || (NOT CC)
          if (orHeaderMnemonic && !useNot)
            PL_strcat(encoding, m_kImapOr);
          if (useNot)
            PL_strcat (encoding, m_kImapNot);
          if (!arbitraryHeader.IsEmpty())
            PL_strcat (encoding, m_kImapHeader);
          PL_strcat (encoding, whichMnemonic);
          if (!ignoreValue)
            err = EncodeImapValue(encoding, value, useQuotes, reallyDredd);
          
          if (orHeaderMnemonic)
          {
            if (useNot)
              PL_strcat(encoding, m_kImapNot);
            
            PL_strcat (encoding, m_kImapHeader);
            
            PL_strcat (encoding, orHeaderMnemonic);
            if (!ignoreValue)
              err = EncodeImapValue(encoding, value, useQuotes, reallyDredd);
          }
          
          // kmcentee, don't let the encoding end with whitespace, 
          // this throws off later url STRCMP
          if (*encoding && *(encoding + strlen(encoding) - 1) == ' ')
            *(encoding + strlen(encoding) - 1) = '\0';
        }
        
        if (value && valueWasAllocated)
          PR_Free (value);
        
        *ppOutTerm = encoding;
        
        return err;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgSearchAdapter::EncodeImapValue ( char *  encoding,
const char *  value,
PRBool  useQuotes,
PRBool  reallyDredd 
) [static, inherited]

Definition at line 735 of file nsMsgSearchAdapter.cpp.

{
  // By NNTP RFC, SEARCH HEADER SUBJECT "" is legal and means 'find messages without a subject header'
  if (!reallyDredd)
  {
    // By IMAP RFC, SEARCH HEADER SUBJECT "" is illegal and will generate an error from the server
    if (!value || !value[0])
      return NS_ERROR_NULL_POINTER;
  }
  
  if (!nsCRT::IsAscii(value))
  {
    nsCAutoString lengthStr;
    PL_strcat(encoding, "{");
    lengthStr.AppendInt((PRInt32) strlen(value));
    PL_strcat(encoding, lengthStr.get());
    PL_strcat(encoding, "}"CRLF);
    PL_strcat(encoding, value);
    return NS_OK;
  }
  if (useQuotes)
    PL_strcat(encoding, "\"");
  PL_strcat (encoding, value);
  if (useQuotes)
    PL_strcat(encoding, "\"");
  
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRUnichar * nsMsgSearchAdapter::EscapeImapSearchProtocol ( const PRUnichar imapCommand) [static, inherited]

Definition at line 226 of file nsMsgSearchAdapter.cpp.

{
       return nsCRT::strdup(imapCommand);
#if 0
       PRUnichar *result = nsnull;
       // max escaped length is one extra character for every character in the cmd.
    PRUnichar *scratchBuf =
        (PRUnichar*) PR_Malloc (sizeof(PRUnichar) * (2*nsCRT::strlen(imapCommand) + 1));
       if (scratchBuf)
       {
              PRUnichar *scratchPtr = scratchBuf;
              while (1)
              {
                     PRUnichar ch = *imapCommand++;
                     if (!ch)
                            break;
                     if (ch == (PRUnichar)'\\')
                     {
                            *scratchPtr++ = (PRUnichar)'\\';
                            *scratchPtr++ = (PRUnichar)'\\';
                     }
                     else
                            *scratchPtr++ = ch;
              }
              *scratchPtr = 0;
        result = nsCRT::strdup (scratchBuf); // realloc down to smaller size
        nsCRT::free (scratchBuf);
       }
       return result;
#endif
}

Here is the caller graph for this function:

Definition at line 265 of file nsMsgSearchAdapter.cpp.

{
       return nsCRT::strdup(imapCommand);
#if 0
       PRUnichar *result = nsnull;
       // max escaped length is one extra character for every character in the cmd.
    PRUnichar *scratchBuf =
        (PRUnichar*) PR_Malloc (sizeof(PRUnichar) * (2*nsCRT::strlen(imapCommand) + 1));
       if (scratchBuf)
       {
              PRUnichar *scratchPtr = scratchBuf;
              while (1)
              {
                     PRUnichar ch = *imapCommand++;
                     if (!ch)
                            break;
                     if (ch == '"')
                     {
                            *scratchPtr++ = '\\';
                            *scratchPtr++ = '"';
                     }
                     else
                            *scratchPtr++ = ch;
              }
              *scratchPtr = '\0';
    result = nsCRT::strdup (scratchBuf); // realloc down to smaller size
    nsCRT::free (scratchBuf);
       }
       return result;
#endif
}
PRUnichar * nsMsgSearchAdapter::EscapeSearchUrl ( const PRUnichar nntpCommand) [static, inherited]

Definition at line 185 of file nsMsgSearchAdapter.cpp.

{
       return nsCRT::strdup(nntpCommand);
#if 0
       PRUnichar *result = nsnull;
       // max escaped length is two extra characters for every character in the cmd.
  PRUnichar *scratchBuf = (PRUnichar*) PR_Malloc(sizeof(PRUnichar) * (3*nsCRT::strlen(nntpCommand) + 1));
       if (scratchBuf)
       {
              PRUnichar *scratchPtr = scratchBuf;
              while (PR_TRUE)
              {
                     PRUnichar ch = *nntpCommand++;
                     if (!ch)
                            break;
                     if (ch == '#' || ch == '?' || ch == '@' || ch == '\\')
                     {
                            *scratchPtr++ = '\\';
                nsTextFormatter::snprintf(scratchPtr, 2,
                                          NS_LITERAL_STRING("%2.2X").get(), ch);
                                   /* Reviewed 4.51 safe use of sprintf */
                            scratchPtr += 2;
                     }
                     else
                            *scratchPtr++ = ch;
              }
              *scratchPtr = '\0';
              result = nsCRT::strdup (scratchBuf); // realloc down to smaller size
        nsCRT::free (scratchBuf);
       }
       return result;
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

Here is the caller graph for this function:

Definition at line 79 of file nsMsgImapSearch.cpp.

Here is the call graph for this function:

char * nsMsgSearchAdapter::GetImapCharsetParam ( const PRUnichar destCharset) [static, inherited]

Definition at line 168 of file nsMsgSearchAdapter.cpp.

{
       char *result = nsnull;

       // Specify a character set unless we happen to be US-ASCII.
  if (nsCRT::strcmp(destCharset, NS_LITERAL_STRING("us-ascii").get()))
           result = PR_smprintf("%s%s", nsMsgSearchAdapter::m_kImapCharset, NS_ConvertUCS2toUTF8(destCharset).get());

       return result;
}

Here is the caller graph for this function:

void nsIMsgSearchAdapter::getSearchCharsets ( out wstring  srcCharset,
out wstring  destCharset 
) [inherited]

Here is the caller graph for this function:

Definition at line 101 of file nsMsgImapSearch.cpp.

{
    // we should never end up here for a purely online
    // folder.  We might for an offline IMAP folder.
    nsresult err = NS_ERROR_NOT_IMPLEMENTED;

    return err;
}
char * nsMsgSearchAdapter::TransformSpacesToStars ( const char *  spaceString,
msg_TransformType  transformType 
) [protected, inherited]

Definition at line 814 of file nsMsgSearchAdapter.cpp.

{
       char *starString;
       
       if (transformType == kOverwrite)
       {
              if ((starString = nsCRT::strdup(spaceString)) != nsnull)
              {
                     char *star = starString;
                     while ((star = PL_strchr(star, ' ')) != nsnull)
                            *star = '*';
              }
       }
       else
       {
              int i, count;

              for (i = 0, count = 0; spaceString[i]; )
              {
                     if (spaceString[i++] == ' ')
                     {
                            count++;
                            while (spaceString[i] && spaceString[i] == ' ') i++;
                     }
              }

              if (transformType == kSurround)
                     count *= 2;

              if (count > 0)
              {
                     if ((starString = (char *)PR_Malloc(i + count + 1)) != nsnull)
                     {
                            int j;

                            for (i = 0, j = 0; spaceString[i]; )
                            {
                                   if (spaceString[i] == ' ')
                                   {
                                          starString[j++] = '*';
                                          starString[j++] = ' ';
                                          if (transformType == kSurround)
                                                 starString[j++] = '*';

                                          i++;
                                          while (spaceString[i] && spaceString[i] == ' ')
                                                 i++;
                                   }
                                   else
                                          starString[j++] = spaceString[i++];
                            }
                            starString[j] = 0;
                     }
              }
              else
                     starString = nsCRT::strdup(spaceString);
       }

       return starString;
}

Here is the call graph for this function:

char * nsMsgSearchAdapter::UnEscapeSearchUrl ( const char *  commandSpecificData) [static, inherited]

Definition at line 298 of file nsMsgSearchAdapter.cpp.

{
  char *result = (char*) PR_Malloc (strlen(commandSpecificData) + 1);
       if (result)
       {
              char *resultPtr = result;
              while (1)
              {
                     char ch = *commandSpecificData++;
                     if (!ch)
                            break;
                     if (ch == '\\')
                     {
                            char scratchBuf[3];
                            scratchBuf[0] = (char) *commandSpecificData++;
                            scratchBuf[1] = (char) *commandSpecificData++;
                            scratchBuf[2] = '\0';
                            unsigned int accum = 0;
                            sscanf (scratchBuf, "%X", &accum);
                            *resultPtr++ = (char) accum;
                     }
                     else
                            *resultPtr++ = ch;
              }
              *resultPtr = '\0';
       }
       return result;
}

Here is the call graph for this function:

Implements nsIMsgSearchAdapter.

Definition at line 59 of file nsMsgImapSearch.cpp.

{
  nsresult err = nsMsgSearchAdapter::ValidateTerms ();
  
  if (NS_SUCCEEDED(err))
  {
      // ### mwelch Figure out the charsets to use 
      //            for the search terms and targets.
      nsXPIDLString srcCharset, dstCharset;
      GetSearchCharsets(getter_Copies(srcCharset), getter_Copies(dstCharset));

      // do IMAP specific validation
      err = Encode (m_encoding, m_searchTerms, dstCharset.get());
      NS_ASSERTION(NS_SUCCEEDED(err), "failed to encode imap search");
  }
  
  return err;
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 63 of file nsIMsgSearchAdapter.idl.

Definition at line 81 of file nsMsgSearchAdapter.h.

Definition at line 82 of file nsMsgSearchAdapter.h.

Definition at line 62 of file nsMsgSearchImap.h.

Definition at line 83 of file nsMsgSearchAdapter.h.

const char * nsMsgSearchAdapter::m_kImapAnswered = " ANSWERED " [static, inherited]

Definition at line 115 of file nsMsgSearchAdapter.h.

const char * nsMsgSearchAdapter::m_kImapAnyText = " TEXT " [static, inherited]

Definition at line 110 of file nsMsgSearchAdapter.h.

const char * nsMsgSearchAdapter::m_kImapBefore = " SENTBEFORE " [static, inherited]

Definition at line 100 of file nsMsgSearchAdapter.h.

const char * nsMsgSearchAdapter::m_kImapBody = " BODY " [static, inherited]

Definition at line 101 of file nsMsgSearchAdapter.h.

const char * nsMsgSearchAdapter::m_kImapCC = " CC " [static, inherited]

Definition at line 102 of file nsMsgSearchAdapter.h.

const char * nsMsgSearchAdapter::m_kImapCharset = " CHARSET " [static, inherited]

Definition at line 118 of file nsMsgSearchAdapter.h.

const char * nsMsgSearchAdapter::m_kImapFlagged = " FLAGGED " [static, inherited]

Definition at line 124 of file nsMsgSearchAdapter.h.

const char * nsMsgSearchAdapter::m_kImapFrom = " FROM " [static, inherited]

Definition at line 103 of file nsMsgSearchAdapter.h.

const char * nsMsgSearchAdapter::m_kImapHeader = " HEADER" [static, inherited]

Definition at line 109 of file nsMsgSearchAdapter.h.

const char * nsMsgSearchAdapter::m_kImapKeyword = " KEYWORD " [static, inherited]

Definition at line 111 of file nsMsgSearchAdapter.h.

const char * nsMsgSearchAdapter::m_kImapNew = " NEW " [static, inherited]

Definition at line 122 of file nsMsgSearchAdapter.h.

const char * nsMsgSearchAdapter::m_kImapNot = " NOT" [static, inherited]

Definition at line 104 of file nsMsgSearchAdapter.h.

const char * nsMsgSearchAdapter::m_kImapNotAnswered = " UNANSWERED " [static, inherited]

Definition at line 117 of file nsMsgSearchAdapter.h.

const char * nsMsgSearchAdapter::m_kImapNotFlagged = " UNFLAGGED " [static, inherited]

Definition at line 125 of file nsMsgSearchAdapter.h.

const char * nsMsgSearchAdapter::m_kImapNotNew = " OLD SEEN " [static, inherited]

Definition at line 123 of file nsMsgSearchAdapter.h.

const char * nsMsgSearchAdapter::m_kImapNotSeen = " UNSEEN " [static, inherited]

Definition at line 116 of file nsMsgSearchAdapter.h.

const char * nsMsgSearchAdapter::m_kImapOr = " OR" [static, inherited]

Definition at line 105 of file nsMsgSearchAdapter.h.

const char * nsMsgSearchAdapter::m_kImapSeen = " SEEN " [static, inherited]

Definition at line 114 of file nsMsgSearchAdapter.h.

const char * nsMsgSearchAdapter::m_kImapSentOn = " SENTON " [static, inherited]

Definition at line 113 of file nsMsgSearchAdapter.h.

const char * nsMsgSearchAdapter::m_kImapSince = " SENTSINCE " [static, inherited]

Definition at line 106 of file nsMsgSearchAdapter.h.

const char * nsMsgSearchAdapter::m_kImapSizeLarger = " LARGER " [static, inherited]

Definition at line 121 of file nsMsgSearchAdapter.h.

const char * nsMsgSearchAdapter::m_kImapSizeSmaller = " SMALLER " [static, inherited]

Definition at line 120 of file nsMsgSearchAdapter.h.

const char * nsMsgSearchAdapter::m_kImapSubject = " SUBJECT " [static, inherited]

Definition at line 107 of file nsMsgSearchAdapter.h.

const char * nsMsgSearchAdapter::m_kImapTo = " TO " [static, inherited]

Definition at line 108 of file nsMsgSearchAdapter.h.

const char * nsMsgSearchAdapter::m_kImapUnDeleted = " UNDELETED" [static, inherited]

Definition at line 119 of file nsMsgSearchAdapter.h.

const char * nsMsgSearchAdapter::m_kNntpKeywords = " KEYWORDS " [static, inherited]

Definition at line 112 of file nsMsgSearchAdapter.h.

NS_DECL_ISUPPORTS NS_DECL_NSIMSGSEARCHADAPTER nsIMsgSearchScopeTerm* nsMsgSearchAdapter::m_scope [inherited]

Definition at line 78 of file nsMsgSearchAdapter.h.

Definition at line 79 of file nsMsgSearchAdapter.h.


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