Beispiel #1
0
//-----------------------------------------------------------------------------
Profile* ProfileManager::GetProfile(const ProfileDeviceKey& deviceKey, const char* user)
{
    Lock::Locker lockScope(&ProfileLock);

    if (ProfileCache == NULL)
    {   // Load the cache
        LoadCache(false);
        if (ProfileCache == NULL)
            return NULL;
    }
    
	Profile* profile = new Profile(BasePath);

	if (deviceKey.Valid)
    {
		if (!profile->LoadDeviceProfile(deviceKey) && (user == NULL))
        {
            profile->Release();
            return NULL;
        }
    }
    
    if (user)
    {
		const char* product_str = deviceKey.ProductName.IsEmpty() ? NULL : deviceKey.ProductName.ToCStr();
		const char* serial_str = deviceKey.PrintedSerial.IsEmpty() ? NULL : deviceKey.PrintedSerial.ToCStr();

        if (!profile->LoadProfile(ProfileCache.GetPtr(), user, product_str, serial_str))
        {
            profile->Release();
            return NULL;
        }
    }

    return profile;
}