Ejemplo n.º 1
0
// After changing any name field you should call this to update PR_INITIALS and PR_DISPLAY_NAME
bool MAPIContact::UpdateDisplayName() {
	String strPrefix, strFirst, strMiddle, strLast, strGeneration, strFullName, strFileAs, strInitials;
	strPrefix = GetDisplayNamePrefix();
	if(strPrefix.GetLength()) {
		strFullName = strPrefix;
		strFullName += ' ';
	}
	strFirst = GetName(PR_GIVEN_NAME);
	if(strFirst.GetLength()) {
		strFileAs += strFirst;
		strInitials += strFirst[0];
		strInitials += '.';
	}
	strMiddle = GetName(PR_MIDDLE_NAME);
	if(strMiddle.GetLength()) {
		if(strFileAs.GetLength()) 
			strFileAs += ' ';
		strFileAs += strMiddle;
		strInitials += strMiddle[0];
		strInitials += '.';

		int i = 1, nLen = strMiddle.GetLength();
		while(i < nLen) {
			if(strMiddle[i-1] == ' ') {
				strInitials += strMiddle[i];
				strInitials += '.';
			}
			i++;
		}
	}
	strLast = GetName(PR_SURNAME);
	if(strLast.GetLength())  {
		if(strFileAs.GetLength()) 
			strFileAs += ' ';
		strFileAs += strLast;
		strInitials += strLast[0];
		strInitials += '.';
	}
	if(strFileAs.GetLength()) 
		strFullName += strFileAs;
	strGeneration = GetGeneration();
	if(strGeneration.GetLength()) {
		if(strFullName.GetLength()) 
			strFullName += ' ';
		strFullName += strGeneration;
	}

#ifdef _WIN32_WCE
	return SetName(strFileAs, PR_DISPLAY_NAME);
#else
	if(!SetPropertyString(PR_INITIALS, strInitials)) 
		return false;
	if(!SetName(strFullName, PR_DISPLAY_NAME)) 
		return false;
	SetOutlookProperty(OUTLOOK_DATA1, OUTLOOK_FILE_AS, strFileAs);
	if(!SetPropertyString(PR_SUBJECT, strFileAs)) 
		return false;
	return SetPropertyString(PR_NORMALIZED_SUBJECT, strFileAs);
#endif
}
Ejemplo n.º 2
0
ResultCode HandleTable::Close(Handle handle) {
    if (!IsValid(handle))
        return ERR_INVALID_HANDLE;

    size_t slot = GetSlot(handle);
    u16 generation = GetGeneration(handle);

    objects[slot] = nullptr;

    generations[generation] = next_free_slot;
    next_free_slot = slot;
    return RESULT_SUCCESS;
}
Ejemplo n.º 3
0
gfxDWriteFont *
gfxDWriteFontGroup::GetFontAt(PRInt32 i) 
{
    // If it turns out to be hard for all clients that cache font
    // groups to call UpdateFontList at appropriate times, we could
    // instead consider just calling UpdateFontList from someplace
    // more central (such as here).
    NS_ASSERTION(!mUserFontSet || mCurrGeneration == GetGeneration(),
                 "Whoever was caching this font group should have "
                 "called UpdateFontList on it");
    NS_ASSERTION(mFonts.Length() > PRUint32(i), 
                 "Requesting a font index that doesn't exist");

    return static_cast<gfxDWriteFont*>(mFonts[i].get());
}
Ejemplo n.º 4
0
bool FAudioDeviceManager::IsValidAudioDeviceHandle(uint32 Handle) const
{
	if (AudioDeviceModule == nullptr || Handle == AUDIO_DEVICE_HANDLE_INVALID)
	{
		return false;
	}

	uint32 Index = GetIndex(Handle);
	if (int32(Index) >= Generations.Num())
	{
		return false;
	}

	uint8 Generation = GetGeneration(Handle);
	return Generations[Index] == Generation;
}
bool FAudioDeviceManager::IsValidAudioDeviceHandle(uint32 Handle) const
{
	if (AudioDeviceModule == nullptr || Handle == INDEX_NONE)
	{
		return false;
	}

	uint32 Index = GetIndex(Handle);
	if (int32(Index) >= Generations.Num())
	{
		return false;
	}

	uint8 Generation = GetGeneration(Handle);
	return Generations[Index] == Generation;
}
Ejemplo n.º 6
0
bool FAudioDeviceManager::ShutdownAudioDevice(uint32 Handle)
{
	if (!IsValidAudioDeviceHandle(Handle))
	{
		return false;
	}

	check(NumActiveAudioDevices > 0);
	--NumActiveAudioDevices;

	// If there are more than 1 device active, check to see if this handle is the main audio device handle
	if (NumActiveAudioDevices >= 1)
	{
		uint32 MainDeviceHandle = GEngine->GetAudioDeviceHandle();

		if (NumActiveAudioDevices == 1)
		{
			// If we only have one audio device left, then set the active
			// audio device to be the main audio device
			SetActiveDevice(MainDeviceHandle);
		}

		// If this is the main device handle and there's more than one reference to the main device, 
		// don't shut it down until it's the very last handle to get shut down
		// this is because it's possible for some PIE sessions to be using the main audio device as a fallback to 
		// preserve CPU performance on low-performance machines
		if (NumWorldsUsingMainAudioDevice > 0 && MainDeviceHandle == Handle)
		{
			--NumWorldsUsingMainAudioDevice;

			return true;
		}
	}

	uint32 Index = GetIndex(Handle);
	uint8 Generation = GetGeneration(Handle);

	check(int32(Index) < Generations.Num());

	// Bump up the generation at the given index. This will invalidate
	// the handle without needing to broadcast to everybody who might be using the handle
	Generations[Index] = ++Generation;

	// Make sure we have a non-null device ptr in the index slot, then delete it
	FAudioDevice* AudioDevice = Devices[Index];
	check(AudioDevice != nullptr);

    // Tear down the audio device
	AudioDevice->Teardown();

	delete AudioDevice;

	// Nullify the audio device slot for future audio device creations
	Devices[Index] = nullptr;

	// Add this index to the list of free indices
	++FreeIndicesSize;
	FreeIndices.Enqueue(Index);

	return true;
}
Ejemplo n.º 7
0
////////////////////////////////////////////////////////////////////////////////
/// CDeviceDrer::StepGeneration(const SettingValue)
///
/// @description Increases the energy generation of this DRER by step.
///
/// @pre None.
/// @post The energy generation has been increased by step.
////////////////////////////////////////////////////////////////////////////////
void CDeviceDrer::StepGeneration(const SettingValue step)
{
    Logger.Trace << __PRETTY_FUNCTION__ << std::endl;
    Set("generation", GetGeneration() + step);
}
Ejemplo n.º 8
0
bool HandleTable::IsValid(Handle handle) const {
    size_t slot = GetSlot(handle);
    u16 generation = GetGeneration(handle);

    return slot < MAX_COUNT && objects[slot] != nullptr && generations[slot] == generation;
}