Esempio n. 1
0
NS_IMETHODIMP nsImportService::GetModuleName(const char *filter, PRInt32 index, PRUnichar **_retval)
{
    NS_PRECONDITION(_retval != nsnull, "null ptr");
    if (!_retval)
        return NS_ERROR_NULL_POINTER;

  *_retval = nsnull;

    DoDiscover();
    if (!m_pModules)
    return NS_ERROR_FAILURE;

  if ((index < 0) || (index >= m_pModules->GetCount()))
    return NS_ERROR_FAILURE;

  ImportModuleDesc *  pDesc;
  PRInt32  count = 0;
  for (PRInt32 i = 0; i < m_pModules->GetCount(); i++) {
    pDesc = m_pModules->GetModuleDesc(i);
    if (pDesc->SupportsThings(filter)) {
      if (count == index) {
        *_retval = NS_strdup(pDesc->GetName());
        return NS_OK;
      }
      else
        count++;
    }
  }

  return NS_ERROR_FAILURE;
}
Esempio n. 2
0
NS_IMETHODIMP nsImportService::GetModuleInfo(const char *filter, PRInt32 index, PRUnichar **name, PRUnichar **moduleDescription)
{
    NS_PRECONDITION(name != nsnull, "null ptr");
    NS_PRECONDITION(moduleDescription != nsnull, "null ptr");
    if (!name || !moduleDescription)
        return NS_ERROR_NULL_POINTER;

  *name = nsnull;
  *moduleDescription = nsnull;

    DoDiscover();
    if (!m_pModules)
    return NS_ERROR_FAILURE;

  if ((index < 0) || (index >= m_pModules->GetCount()))
    return NS_ERROR_FAILURE;

  ImportModuleDesc *  pDesc;
  PRInt32  count = 0;
  for (PRInt32 i = 0; i < m_pModules->GetCount(); i++) {
    pDesc = m_pModules->GetModuleDesc(i);
    if (pDesc->SupportsThings(filter)) {
      if (count == index) {
        *name = NS_strdup(pDesc->GetName());
        *moduleDescription = NS_strdup(pDesc->GetDescription());
        return NS_OK;
      }
      else
        count++;
    }
  }

  return NS_ERROR_FAILURE;
}