Back to index

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

#include <winEmbedFileLocProvider.h>

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

List of all members.

Public Member Functions

 winEmbedFileLocProvider (const char *productDirName)
 winEmbedFileLocProvider (const nsACString &aProductDirName)
nsIFile getFile (in string prop, out PRBool persistent)
 getFile

Protected Member Functions

virtual ~winEmbedFileLocProvider ()
NS_METHOD CloneMozBinDirectory (nsILocalFile **aLocalFile)
NS_METHOD GetProductDirectory (nsILocalFile **aLocalFile)
NS_METHOD GetDefaultUserProfileRoot (nsILocalFile **aLocalFile)
NS_METHOD GetGreDirectory (nsILocalFile **aLocalFile)
virtual ~winEmbedFileLocProvider ()
NS_METHOD CloneMozBinDirectory (nsILocalFile **aLocalFile)
NS_METHOD GetProductDirectory (nsILocalFile **aLocalFile)
NS_METHOD GetDefaultUserProfileRoot (nsILocalFile **aLocalFile)

Protected Attributes

char mProductDirName [256]
nsCOMPtr< nsILocalFilemMozBinDirectory
nsEmbedCString mProductDirName

Detailed Description

Definition at line 49 of file winEmbedFileLocProvider.h.


Constructor & Destructor Documentation

Definition at line 71 of file winEmbedFileLocProvider.cpp.

{
    strncpy(mProductDirName, productDirName, sizeof(mProductDirName) - 1);
    mProductDirName[sizeof(mProductDirName) - 1] = '\0';
}

Definition at line 77 of file winEmbedFileLocProvider.cpp.

{
}
winEmbedFileLocProvider::winEmbedFileLocProvider ( const nsACString &  aProductDirName)

Definition at line 64 of file winEmbedFileLocProvider.cpp.

{
    mProductDirName = aAppDataDirName;
}
virtual winEmbedFileLocProvider::~winEmbedFileLocProvider ( ) [protected, virtual]

Member Function Documentation

Definition at line 271 of file winEmbedFileLocProvider.cpp.

{
    NS_ENSURE_ARG_POINTER(aLocalFile);
    nsresult rv;
    
    if (!mMozBinDirectory)
    {        
        // Get the mozilla bin directory
        // 1. Check the directory service first for NS_XPCOM_CURRENT_PROCESS_DIR
        //    This will be set if a directory was passed to NS_InitXPCOM
        // 2. If that doesn't work, set it to be the current process directory
        
        nsCOMPtr<nsIProperties> directoryService = 
                 do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
        if (NS_FAILED(rv))
            return rv;
        
        rv = directoryService->Get(NS_XPCOM_CURRENT_PROCESS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(mMozBinDirectory));
        if (NS_FAILED(rv)) {
            rv = directoryService->Get(NS_OS_CURRENT_PROCESS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(mMozBinDirectory));
            if (NS_FAILED(rv))
                return rv;
        }
    }
    
    nsCOMPtr<nsIFile> aFile;
    rv = mMozBinDirectory->Clone(getter_AddRefs(aFile));
    if (NS_FAILED(rv))
        return rv;

    nsCOMPtr<nsILocalFile> lfile = do_QueryInterface (aFile);
    if (!lfile)
        return NS_ERROR_FAILURE;
    
    NS_IF_ADDREF(*aLocalFile = lfile);
    return NS_OK;
}

Here is the call graph for this function:

Definition at line 356 of file winEmbedFileLocProvider.cpp.

{
    NS_ENSURE_ARG_POINTER(aLocalFile);
    
    nsresult rv;
    PRBool exists;
    nsCOMPtr<nsILocalFile> localDir;
   
    rv = GetProductDirectory(getter_AddRefs(localDir));
    if (NS_FAILED(rv)) return rv;

    // These 3 platforms share this part of the path - do them as one
    rv = localDir->AppendRelativeNativePath(PROFILE_ROOT_DIR_NAME);
    if (NS_FAILED(rv)) return rv;
    rv = localDir->Exists(&exists);
    if (NS_SUCCEEDED(rv) && !exists)
        rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0775);
    if (NS_FAILED(rv)) return rv;

    *aLocalFile = localDir;
    NS_ADDREF(*aLocalFile);

   return rv; 
}

Here is the call graph for this function:

nsIFile nsIDirectoryServiceProvider::getFile ( in string  prop,
out PRBool  persistent 
) [inherited]

getFile

Directory Service calls this when it gets the first request for a prop or on every request if the prop is not persistent.

Parameters:
propThe symbolic name of the file.
persistentTRUE - The returned file will be cached by Directory Service. Subsequent requests for this prop will bypass the provider and use the cache. FALSE - The provider will be asked for this prop each time it is requested.
Returns:
The file represented by the property.

Definition at line 244 of file winEmbedFileLocProvider.cpp.

{
    NS_ENSURE_ARG_POINTER(aLocalFile);
    nsresult rv = NS_ERROR_FAILURE;

    // Get the path of the GRE which is compatible with our embedding application
    // from the registry
    //
    char *pGreDir = GetGreLocationFromRegistry();
    if(pGreDir)
    {
        nsCOMPtr<nsILocalFile> tempLocal;
           rv = NS_NewNativeLocalFile(nsDependentCString(pGreDir), TRUE, getter_AddRefs(tempLocal));

        if (tempLocal)
        {
           *aLocalFile = tempLocal;
           NS_ADDREF(*aLocalFile);
           rv = NS_OK;
        }

        ::free(pGreDir);
    }

    return rv;
}

Here is the call graph for this function:

Definition at line 315 of file winEmbedFileLocProvider.cpp.

{
    NS_ENSURE_ARG_POINTER(aLocalFile);
    
    nsresult rv;
    PRBool exists;
    nsCOMPtr<nsILocalFile> localDir;
   
    nsCOMPtr<nsIProperties> directoryService = 
             do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
    if (NS_FAILED(rv)) return rv;
    rv = directoryService->Get(NS_WIN_APPDATA_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir));
    if (NS_SUCCEEDED(rv))
        rv = localDir->Exists(&exists);
    if (NS_FAILED(rv) || !exists)
    {
        // On some Win95 machines, NS_WIN_APPDATA_DIR does not exist - revert to NS_WIN_WINDOWS_DIR
        localDir = nsnull;
        rv = directoryService->Get(NS_WIN_WINDOWS_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir));
    }
    if (NS_FAILED(rv)) return rv;

    rv = localDir->AppendRelativeNativePath(nsDependentCString(mProductDirName));
    if (NS_FAILED(rv)) return rv;
    rv = localDir->Exists(&exists);
    if (NS_SUCCEEDED(rv) && !exists)
        rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0775);
    if (NS_FAILED(rv)) return rv;

    *aLocalFile = localDir;
    NS_ADDREF(*aLocalFile);

   return rv; 
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 68 of file winEmbedFileLocProvider.h.

Definition at line 61 of file winEmbedFileLocProvider.h.

Definition at line 67 of file winEmbedFileLocProvider.h.


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