Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
ProfileStruct Class Reference

#include <nsProfileAccess.h>

Collaboration diagram for ProfileStruct:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ProfileStruct ()
 ProfileStruct (const ProfileStruct &src)
 ~ProfileStruct ()
ProfileStructoperator= (const ProfileStruct &rhs)
nsresult GetResolvedProfileDir (nsILocalFile **aDirectory)
nsresult SetResolvedProfileDir (nsILocalFile *aDirectory)
nsresult CopyProfileLocation (ProfileStruct *destStruct)
nsresult InternalizeLocation (nsIRegistry *aRegistry, nsRegistryKey profKey, PRBool is4x)
nsresult ExternalizeLocation (nsIRegistry *aRegistry, nsRegistryKey profKey)
nsresult InternalizeMigratedFromLocation (nsIRegistry *aRegistry, nsRegistryKey profKey)
nsresult ExternalizeMigratedFromLocation (nsIRegistry *aRegistry, nsRegistryKey profKey)

Public Attributes

nsString profileName
PRBool isMigrated
nsCOMPtr< nsILocalFilemigratedFrom
nsString NCProfileName
nsString NCDeniedService
nsString NCEmailAddress
nsString NCHavePregInfo
PRBool updateProfileEntry
PRBool isImportType
PRInt64 creationTime
PRInt64 lastModTime

Private Member Functions

nsresult EnsureDirPathExists (nsILocalFile *aFile, PRBool *wasCreated)

Private Attributes

nsString regLocationData
nsCOMPtr< nsILocalFileresolvedLocation

Detailed Description

Definition at line 61 of file nsProfileAccess.h.


Constructor & Destructor Documentation

Definition at line 1253 of file nsProfileAccess.cpp.

{
    *this = src;
}

Definition at line 67 of file nsProfileAccess.h.

{ }

Member Function Documentation

Definition at line 1316 of file nsProfileAccess.cpp.

{
    if (resolvedLocation)
    {
        nsCOMPtr<nsIFile> file;
        nsresult rv = resolvedLocation->Clone(getter_AddRefs(file));
        if (NS_SUCCEEDED(rv))
            destStruct->resolvedLocation = do_QueryInterface(file, &rv);
        if (NS_FAILED(rv)) return rv;
    }
    destStruct->regLocationData = regLocationData;

    return NS_OK;
}

Here is the call graph for this function:

nsresult ProfileStruct::EnsureDirPathExists ( nsILocalFile aFile,
PRBool wasCreated 
) [private]

Definition at line 1514 of file nsProfileAccess.cpp.

{
    NS_ENSURE_ARG(aDir);
    NS_ENSURE_ARG_POINTER(wasCreated);
    *wasCreated = PR_FALSE;

    nsresult rv;
    PRBool exists;
    rv = aDir->Exists(&exists);
    if (NS_SUCCEEDED(rv) && !exists)
    {
        rv = aDir->Create(nsIFile::DIRECTORY_TYPE, 0700);
        *wasCreated = NS_SUCCEEDED(rv);
    }
    return rv;
}

Here is the caller graph for this function:

Definition at line 1416 of file nsProfileAccess.cpp.

{
    nsresult rv;

    if (resolvedLocation)
    {
        nsAutoString regData;

#if defined(XP_MAC) || defined(XP_MACOSX)
        PRBool leafCreated;
        nsCAutoString descBuf;

        // It must exist before we try to use GetPersistentDescriptor
        rv = EnsureDirPathExists(resolvedLocation, &leafCreated);
        if (NS_FAILED(rv)) return rv;
        rv = resolvedLocation->GetPersistentDescriptor(descBuf);
        if (NS_FAILED(rv)) return rv;
        if (leafCreated)
            resolvedLocation->Remove(PR_FALSE);
        AppendUTF8toUTF16(descBuf, regData);
#else
        rv = resolvedLocation->GetPath(regData);
        if (NS_FAILED(rv)) return rv;
#endif

        rv = aRegistry->SetString(profKey,
                                 kRegistryDirectoryString.get(),
                                 regData.get());

    }
    else if (!regLocationData.IsEmpty())
    {
        // Write the original data back out - maybe it can be resolved later.
        rv = aRegistry->SetString(profKey,
                                 kRegistryDirectoryString.get(),
                                 regLocationData.get());
    }
    else
    {
        NS_ASSERTION(PR_FALSE, "ProfileStruct has no location data!");
        rv = NS_ERROR_FAILURE;
    }

    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1491 of file nsProfileAccess.cpp.

{
    nsresult rv = NS_OK;
    nsCAutoString regData;

    if (migratedFrom)
    {
#if defined(XP_MAC) || defined(XP_MACOSX)
        rv = migratedFrom->GetPersistentDescriptor(regData);
#else
        nsAutoString path;
        rv = migratedFrom->GetPath(path);
        AppendUTF16toUTF8(path, regData);
#endif

        if (NS_SUCCEEDED(rv))
            rv = aRegistry->SetStringUTF8(profKey,
                                          kRegistryMigratedFromString.get(),
                                          regData.get());
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1295 of file nsProfileAccess.cpp.

{
    NS_ENSURE_ARG_POINTER(aDirectory);
    *aDirectory = nsnull;
    if (resolvedLocation)
    {
        *aDirectory = resolvedLocation;
        NS_ADDREF(*aDirectory);
        return NS_OK;
    }
    return NS_ERROR_FILE_NOT_FOUND; // The only reason it would not exist.
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1331 of file nsProfileAccess.cpp.

{
    nsresult rv;
    nsCOMPtr<nsILocalFile> tempLocal;

    // Reset ourselves
    regLocationData.SetLength(0);
    resolvedLocation = nsnull;

    if (is4x)
    {
        nsXPIDLString profLoc;

        rv = aRegistry->GetString( profKey, NS_LITERAL_STRING("ProfileLocation").get(), getter_Copies(profLoc));
        if (NS_FAILED(rv)) return rv;
        regLocationData = profLoc;

#if defined(XP_MAC) || defined(XP_MACOSX)
        // 4.x profiles coming from japanese machine are already in unicode.
        // So, there is no need to decode into unicode further.

        // Unescape profile location
        NS_ConvertUTF16toUTF8 tempLoc(profLoc);
        nsCAutoString profileLocation(nsUnescape(tempLoc.BeginWriting()));
        NS_ConvertUTF8toUTF16 convertedProfLoc(profileLocation);

        // Now we have a unicode path - make it into a file
        // This is an HFS style path, which can't be used with nsIFile, so convert it.
        rv = NS_ERROR_FAILURE;
        CFStringRef pathStrRef = ::CFStringCreateWithCharacters(NULL,
                                      convertedProfLoc.get(), convertedProfLoc.Length());
        if (pathStrRef)
        {
            CFURLRef pathURLRef = ::CFURLCreateWithFileSystemPath(NULL, pathStrRef, kCFURLHFSPathStyle, true);
            if (pathURLRef)
            {
                rv = NS_NewNativeLocalFile(EmptyCString(), PR_TRUE, getter_AddRefs(tempLocal));
                if (NS_SUCCEEDED(rv))
                {
                    nsCOMPtr<nsILocalFileMac> tempLocalMac(do_QueryInterface(tempLocal));
                    rv = tempLocalMac->InitWithCFURL(pathURLRef);
                }
                ::CFRelease(pathURLRef);
            }
            ::CFRelease(pathStrRef);
        }
#else        
        // Unescape profile location and convert it to the right format
        nsCAutoString tempLoc;
        rv = NS_CopyUnicodeToNative(profLoc, tempLoc); 
        NS_ASSERTION(NS_SUCCEEDED(rv), 
                     "failed to convert profile location to native encoding");
        nsCAutoString profileLocation(nsUnescape(tempLoc.BeginWriting()));
        rv = NS_NewNativeLocalFile(profileLocation, PR_TRUE, getter_AddRefs(tempLocal));
#endif
    }
    else
    {
        nsXPIDLString regData;

        rv = aRegistry->GetString(profKey,
                                  kRegistryDirectoryString.get(),
                                  getter_Copies(regData));
        if (NS_FAILED(rv)) return rv;
        regLocationData = regData;

#if defined(XP_MAC) || defined(XP_MACOSX)
            rv = NS_NewNativeLocalFile(EmptyCString(), PR_TRUE, getter_AddRefs(tempLocal));
        if (NS_SUCCEEDED(rv)) // regLocationData is ASCII so no loss
            rv = tempLocal->SetPersistentDescriptor(NS_LossyConvertUCS2toASCII(regLocationData));
#else
        rv = NS_NewLocalFile(regLocationData, PR_TRUE, getter_AddRefs(tempLocal));
#endif
    }

    if (NS_SUCCEEDED(rv) && tempLocal)
    {
        PRBool exists;
        if (NS_SUCCEEDED(tempLocal->Exists(&exists)) && exists)
            SetResolvedProfileDir(tempLocal);
    }

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1462 of file nsProfileAccess.cpp.

{
    nsresult rv;
    nsXPIDLCString regData;
    nsCOMPtr<nsILocalFile> tempLocal;

    rv = aRegistry->GetStringUTF8(profKey,
                                  kRegistryMigratedFromString.get(),
                                  getter_Copies(regData));
    if (NS_SUCCEEDED(rv))
    {
#if defined(XP_MAC) || defined(XP_MACOSX)
        rv = NS_NewLocalFile(EmptyString(), PR_TRUE, getter_AddRefs(tempLocal));
        if (NS_SUCCEEDED(rv))
        {
            // The persistent desc on Mac is base64 encoded so plain ASCII
            rv = tempLocal->SetPersistentDescriptor(regData);
            if (NS_SUCCEEDED(rv))
                migratedFrom = tempLocal;
        }
#else
        rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(regData), PR_TRUE, getter_AddRefs(tempLocal));
        if (NS_SUCCEEDED(rv))
            migratedFrom = tempLocal;
#endif
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ProfileStruct & ProfileStruct::operator= ( const ProfileStruct rhs)

Definition at line 1308 of file nsProfileAccess.cpp.

{
    NS_ENSURE_ARG(aDirectory);
    resolvedLocation = aDirectory;
    regLocationData.SetLength(0);
    return NS_OK;
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 119 of file nsProfileAccess.h.

Definition at line 115 of file nsProfileAccess.h.

Definition at line 103 of file nsProfileAccess.h.

Definition at line 120 of file nsProfileAccess.h.

Definition at line 107 of file nsProfileAccess.h.

Definition at line 110 of file nsProfileAccess.h.

Definition at line 111 of file nsProfileAccess.h.

Definition at line 112 of file nsProfileAccess.h.

Definition at line 109 of file nsProfileAccess.h.

Definition at line 102 of file nsProfileAccess.h.

Definition at line 127 of file nsProfileAccess.h.

Definition at line 128 of file nsProfileAccess.h.

Definition at line 113 of file nsProfileAccess.h.


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