NS_IMETHODIMP nsAbMDBDirectory::GetChildNodes(nsISimpleEnumerator* *aResult)
{
  if (mIsQueryURI)
    return NS_NewEmptyEnumerator(aResult);

  return NS_NewArrayEnumerator(aResult, mSubDirectories);
}
Ejemplo n.º 2
0
NS_IMETHODIMP
nsHTTPIndex::GetTargets(nsIRDFResource *aSource, nsIRDFResource *aProperty, PRBool aTruthValue,
			nsISimpleEnumerator **_retval)
{
	nsresult	rv = NS_ERROR_UNEXPECTED;

	if (mInner)
	{
		rv = mInner->GetTargets(aSource, aProperty, aTruthValue, _retval);
	}
	else
	{
		rv = NS_NewEmptyEnumerator(_retval);
	}

	if ((aProperty == kNC_Child) && isWellknownContainerURI(aSource))
	{
		PRBool		doNetworkRequest = PR_TRUE;
		if (NS_SUCCEEDED(rv) && (_retval))
		{
			// check and see if we already have data for the search in question;
			// if we do, don't bother doing the search again
			PRBool hasResults;
			if (NS_SUCCEEDED((*_retval)->HasMoreElements(&hasResults)) &&
			    hasResults)
			  doNetworkRequest = PR_FALSE;
		}

        // Note: if we need to do a network request, do it out-of-band
        // (because the XUL template builder isn't re-entrant)
        // by using a global connection list and an immediately-firing timer
		if (doNetworkRequest && mConnectionList)
		{
		    PRInt32 connectionIndex = mConnectionList->IndexOf(aSource);
		    if (connectionIndex < 0)
		    {
    		    // add aSource into list of connections to make
	    	    mConnectionList->AppendElement(aSource);

                // if we don't have a timer about to fire, create one
                // which should fire as soon as possible (out-of-band)
            	if (!mTimer)
            	{
            		mTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
            		NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create a timer");
            		if (NS_SUCCEEDED(rv))
            		{
                		mTimer->InitWithFuncCallback(nsHTTPIndex::FireTimer, this, 1,
                		    nsITimer::TYPE_ONE_SHOT);
                		// Note: don't addref "this" as we'll cancel the
                		// timer in the httpIndex destructor
            		}
            	}
	    	}
		}
	}

	return(rv);
}
Ejemplo n.º 3
0
NS_IMETHODIMP
nsAppFileLocationProvider::GetFiles(const char* aProp,
                                    nsISimpleEnumerator** aResult)
{
  if (NS_WARN_IF(!aResult)) {
    return NS_ERROR_INVALID_ARG;
  }
  *aResult = nullptr;
  nsresult rv = NS_ERROR_FAILURE;

  if (!nsCRT::strcmp(aProp, NS_APP_PLUGINS_DIR_LIST)) {
#ifdef MOZ_WIDGET_COCOA
    // As of Java for Mac OS X 10.5 Update 10, Apple has (in effect) deprecated Java Plugin2 on
    // on OS X 10.5, and removed the soft link to it from /Library/Internet Plug-Ins/.  Java
    // Plugin2 is still present and usable, but there are no longer any links to it in the
    // "normal" locations.  So we won't be able to find it unless we look in the "non-normal"
    // location where it actually is.  Safari can use the WebKit-specific JavaPluginCocoa.bundle,
    // which (of course) is still fully supported on OS X 10.5.  But we have no alternative to
    // using Java Plugin2.  For more information see bug 668639.
    static const char* keys[] = {
      NS_APP_PLUGINS_DIR,
      NS_MACOSX_USER_PLUGIN_DIR,
      NS_MACOSX_LOCAL_PLUGIN_DIR,
      IsOSXLeopard() ? NS_MACOSX_JAVA2_PLUGIN_DIR : nullptr,
      nullptr
    };
    *aResult = new nsAppDirectoryEnumerator(this, keys);
#else
#ifdef XP_UNIX
    static const char* keys[] = { nullptr, NS_USER_PLUGINS_DIR, NS_APP_PLUGINS_DIR, NS_SYSTEM_PLUGINS_DIR, nullptr };
#else
    static const char* keys[] = { nullptr, NS_USER_PLUGINS_DIR, NS_APP_PLUGINS_DIR, nullptr };
#endif
    if (!keys[0] && !(keys[0] = PR_GetEnv("MOZ_PLUGIN_PATH"))) {
      static const char nullstr = 0;
      keys[0] = &nullstr;
    }
    *aResult = new nsPathsDirectoryEnumerator(this, keys);
#endif
    NS_ADDREF(*aResult);
    rv = NS_OK;
  }
  if (!nsCRT::strcmp(aProp, NS_APP_SEARCH_DIR_LIST)) {
    static const char* keys[] = { nullptr, NS_APP_USER_SEARCH_DIR, nullptr };
    if (!keys[0] && !(keys[0] = PR_GetEnv("MOZ_SEARCH_ENGINE_PATH"))) {
      static const char nullstr = 0;
      keys[0] = &nullstr;
    }
    *aResult = new nsPathsDirectoryEnumerator(this, keys);
    NS_ADDREF(*aResult);
    rv = NS_OK;
  }
  if (!strcmp(aProp, NS_APP_DISTRIBUTION_SEARCH_DIR_LIST)) {
    return NS_NewEmptyEnumerator(aResult);
  }
  return rv;
}
Ejemplo n.º 4
0
NS_IMETHODIMP
nsObserverService::EnumerateObservers(const char* aTopic,
                                      nsISimpleEnumerator** anEnumerator)
{
    NS_ENSURE_VALIDCALL
    NS_ENSURE_ARG(aTopic && anEnumerator);

    nsObserverList *observerList = mObserverTopicTable.GetEntry(aTopic);
    if (!observerList)
        return NS_NewEmptyEnumerator(anEnumerator);

    return observerList->GetObserverList(anEnumerator);
}
Ejemplo n.º 5
0
NS_IMETHODIMP nsAbLDAPDirectory::GetChildCards(nsISimpleEnumerator** result)
{
    nsresult rv;

    // when offline, we need to get the child cards for the local, replicated mdb directory
    PRBool offline;
    nsCOMPtr <nsIIOService> ioService = do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
    NS_ENSURE_SUCCESS(rv,rv);
    rv = ioService->GetOffline(&offline);
    NS_ENSURE_SUCCESS(rv,rv);

    if (offline) {
        nsCString fileName;
        rv = GetReplicationFileName(fileName);
        NS_ENSURE_SUCCESS(rv,rv);

        // if there is no fileName, bail out now.
        if (fileName.IsEmpty())
            return NS_OK;

        // perform the same query, but on the local directory
        nsCAutoString localDirectoryURI(NS_LITERAL_CSTRING(kMDBDirectoryRoot));
        localDirectoryURI.Append(fileName);
        if (mIsQueryURI)
        {
            localDirectoryURI.AppendLiteral("?");
            localDirectoryURI.Append(mQueryString);
        }

        nsCOMPtr<nsIAbManager> abManager(do_GetService(NS_ABMANAGER_CONTRACTID,
                                         &rv));
        NS_ENSURE_SUCCESS(rv, rv);

        nsCOMPtr <nsIAbDirectory> directory;
        rv = abManager->GetDirectory(localDirectoryURI,
                                     getter_AddRefs(directory));
        NS_ENSURE_SUCCESS(rv, rv);

        rv = directory->GetChildCards(result);
    }
    else {
        // Start the search
        rv = StartSearch();
        NS_ENSURE_SUCCESS(rv, rv);

        rv = NS_NewEmptyEnumerator(result);
    }

    NS_ENSURE_SUCCESS(rv,rv);
    return rv;
}
Ejemplo n.º 6
0
NS_IMETHODIMP
nsHTTPIndex::GetSources(nsIRDFResource *aProperty, nsIRDFNode *aTarget, PRBool aTruthValue,
			nsISimpleEnumerator **_retval)
{
	nsresult	rv = NS_ERROR_UNEXPECTED;

	if (mInner)
	{
		rv = mInner->GetSources(aProperty, aTarget, aTruthValue, _retval);
	}
	else
	{
		rv = NS_NewEmptyEnumerator(_retval);
	}
	return(rv);
}
NS_IMETHODIMP
FileSystemDataSource::ArcLabelsOut(nsIRDFResource *source,
                                   nsISimpleEnumerator **labels /* out */)
{
    NS_PRECONDITION(source != nullptr, "null ptr");
    if (! source)
        return NS_ERROR_NULL_POINTER;

    NS_PRECONDITION(labels != nullptr, "null ptr");
    if (! labels)
        return NS_ERROR_NULL_POINTER;

    if (source == mNC_FileSystemRoot)
    {
        nsCOMArray<nsIRDFResource> resources;
        resources.SetCapacity(2);

        resources.AppendObject(mNC_Child);
        resources.AppendObject(mNC_pulse);

        return NS_NewArrayEnumerator(labels, resources);
    }
    else if (isFileURI(source))
    {
        nsCOMArray<nsIRDFResource> resources;
        resources.SetCapacity(2);

        if (isDirURI(source))
        {
#ifdef  XP_WIN
            if (isValidFolder(source))
            {
                resources.AppendObject(mNC_Child);
            }
#else
            resources.AppendObject(mNC_Child);
#endif
            resources.AppendObject(mNC_pulse);
        }

        return NS_NewArrayEnumerator(labels, resources);
    }

    return NS_NewEmptyEnumerator(labels);
}
NS_IMETHODIMP
sbTemporaryMediaItem::GetPropertyIDs(nsIStringEnumerator** aPropertyIDs)
{
  // Validate arguments.
  NS_ENSURE_ARG_POINTER(aPropertyIDs);

  // Function variables.
  nsresult rv;

  // Create an empty property ID enumerator.
  nsCOMPtr<nsISimpleEnumerator> propertyIDs;
  rv = NS_NewEmptyEnumerator(getter_AddRefs(propertyIDs));
  NS_ENSURE_SUCCESS(rv, rv);
  rv = CallQueryInterface(propertyIDs, aPropertyIDs);
  NS_ENSURE_SUCCESS(rv, rv);

  return NS_OK;
}
/* nsISimpleEnumerator ArcLabelsIn (in nsIRDFNode aNode); */
NS_IMETHODIMP
nsMsgRDFDataSource::ArcLabelsIn(nsIRDFNode *aNode, nsISimpleEnumerator **_retval)
{
  return NS_NewEmptyEnumerator(_retval);
}
Ejemplo n.º 10
0
NS_IMETHODIMP
LocalStoreImpl::GetAllCmds(nsIRDFResource* aSource,
                               nsISimpleEnumerator/*<nsIRDFResource>*/** aCommands)
{
	return(NS_NewEmptyEnumerator(aCommands));
}
Ejemplo n.º 11
0
NS_IMETHODIMP nsAbLDAPDirectory::GetChildNodes(nsISimpleEnumerator* *aResult)
{
    return NS_NewEmptyEnumerator(aResult);
}
NS_IMETHODIMP
FileSystemDataSource::GetAllCmds(nsIRDFResource* source,
                                 nsISimpleEnumerator/*<nsIRDFResource>*/** commands)
{
    return(NS_NewEmptyEnumerator(commands));
}
NS_IMETHODIMP
FileSystemDataSource::GetTargets(nsIRDFResource *source,
                                 nsIRDFResource *property,
                                 bool tv,
                                 nsISimpleEnumerator **targets /* out */)
{
    NS_PRECONDITION(source != nullptr, "null ptr");
    if (! source)
        return NS_ERROR_NULL_POINTER;

    NS_PRECONDITION(property != nullptr, "null ptr");
    if (! property)
        return NS_ERROR_NULL_POINTER;

    NS_PRECONDITION(targets != nullptr, "null ptr");
    if (! targets)
        return NS_ERROR_NULL_POINTER;

    *targets = nullptr;

    // we only have positive assertions in the file system data source.
    if (! tv)
        return NS_RDF_NO_VALUE;

    nsresult rv;

    if (source == mNC_FileSystemRoot)
    {
        if (property == mNC_Child)
        {
            return GetVolumeList(targets);
        }
        else if (property == mNC_pulse)
        {
            nsCOMPtr<nsIRDFLiteral> pulseLiteral;
            mRDFService->GetLiteral(MOZ_UTF16("12"),
                                    getter_AddRefs(pulseLiteral));
            return NS_NewSingletonEnumerator(targets, pulseLiteral);
        }
    }
    else if (isFileURI(source))
    {
        if (property == mNC_Child)
        {
            return GetFolderList(source, false, false, targets);
        }
        else if (property == mNC_Name)
        {
            nsCOMPtr<nsIRDFLiteral> name;
            rv = GetName(source, getter_AddRefs(name));
            if (NS_FAILED(rv)) return rv;

            return NS_NewSingletonEnumerator(targets, name);
        }
        else if (property == mNC_URL)
        {
            nsCOMPtr<nsIRDFLiteral> url;
            rv = GetURL(source, nullptr, getter_AddRefs(url));
            if (NS_FAILED(rv)) return rv;

            return NS_NewSingletonEnumerator(targets, url);
        }
        else if (property == mRDF_type)
        {
            nsCString uri;
            rv = mNC_FileSystemObject->GetValueUTF8(uri);
            if (NS_FAILED(rv)) return rv;

            NS_ConvertUTF8toUTF16 url(uri);

            nsCOMPtr<nsIRDFLiteral> literal;
            rv = mRDFService->GetLiteral(url.get(), getter_AddRefs(literal));
            if (NS_FAILED(rv)) return rv;

            return NS_NewSingletonEnumerator(targets, literal);
        }
        else if (property == mNC_pulse)
        {
            nsCOMPtr<nsIRDFLiteral> pulseLiteral;
            rv = mRDFService->GetLiteral(MOZ_UTF16("12"),
                                         getter_AddRefs(pulseLiteral));
            if (NS_FAILED(rv)) return rv;

            return NS_NewSingletonEnumerator(targets, pulseLiteral);
        }
    }

    return NS_NewEmptyEnumerator(targets);
}