Пример #1
0
nsresult
nsMsgSearchValidityTable::ValidateTerms (nsISupportsArray *searchTerms)
{
  nsresult err = NS_OK;
  PRUint32 count;

  NS_ENSURE_ARG(searchTerms);

  searchTerms->Count(&count);
  for (PRUint32 i = 0; i < count; i++)
  {
    nsCOMPtr<nsIMsgSearchTerm> pTerm;
    searchTerms->QueryElementAt(i, NS_GET_IID(nsIMsgSearchTerm),
                             (void **)getter_AddRefs(pTerm));

    nsIMsgSearchTerm *iTerm = pTerm;
    nsMsgSearchTerm *term = static_cast<nsMsgSearchTerm *>(iTerm);
//    XP_ASSERT(term->IsValid());
        bool enabled;
        bool available;
        GetEnabled(term->m_attribute, term->m_operator, &enabled);
        GetAvailable(term->m_attribute, term->m_operator, &available);
    if (!enabled || !available)
    {
            bool validNotShown;
            GetValidButNotShown(term->m_attribute, term->m_operator,
                                &validNotShown);
            if (!validNotShown)
        err = NS_MSG_ERROR_INVALID_SEARCH_SCOPE;
    }
  }

  return err;
}
nsresult nsMsgSearchValidityTable::ValidateTerms(nsIArray *searchTerms) {
  nsresult rv = NS_OK;
  uint32_t count;

  NS_ENSURE_ARG_POINTER(searchTerms);

  searchTerms->GetLength(&count);
  for (uint32_t i = 0; i < count; i++) {
    nsCOMPtr<nsIMsgSearchTerm> pTerm = do_QueryElementAt(searchTerms, i);

    nsIMsgSearchTerm *iTerm = pTerm;
    nsMsgSearchTerm *term = static_cast<nsMsgSearchTerm *>(iTerm);
    //    XP_ASSERT(term->IsValid());
    bool enabled;
    bool available;
    rv = GetEnabled(term->m_attribute, term->m_operator, &enabled);
    NS_ENSURE_SUCCESS(rv, rv);
    rv = GetAvailable(term->m_attribute, term->m_operator, &available);
    NS_ENSURE_SUCCESS(rv, rv);
    if (!enabled || !available) {
      bool validNotShown;
      rv = GetValidButNotShown(term->m_attribute, term->m_operator,
                               &validNotShown);
      NS_ENSURE_SUCCESS(rv, rv);
      if (!validNotShown) return NS_MSG_ERROR_INVALID_SEARCH_SCOPE;
    }
  }

  return rv;
}