realtimenetprots/sipfw/SIP/TransactionUser/src/RestoreUaState.cpp
author William Roberts <williamr@symbian.org>
Mon, 08 Mar 2010 21:43:52 +0000
branchCompilerCompatibility
changeset 6 f5380f579f8b
parent 0 307788aac0a8
permissions -rw-r--r--
Create CompilerCompatibility branch

// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of "Eclipse Public License v1.0"
// which accompanies this distribution, and is available
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
//
// Initial Contributors:
// Nokia Corporation - initial contribution.
//
// Contributors:
//
// Description:
// Name          : RestoreUaState.cpp
// Part of       : TransactionUser
// Version       : SIP/4.0
//



#include "SipAssert.h"
#include "RestoreUaState.h"
#include "CUserAgent.h"

// -----------------------------------------------------------------------------
// TRestoreUaState::TRestoreUaState
// Either both aUserAgent and aTimer must be defined, or neither can.
// -----------------------------------------------------------------------------
//
TRestoreUaState::TRestoreUaState(TBool& aFinalRespPassed,
								 CUserAgent* aUserAgent,
								 CUserAgentTimer* aTimer) :
    iFinalRespPassed(aFinalRespPassed),
    iOriginalValue(iFinalRespPassed),
    iUserAgent(aUserAgent),
    iTimer(aTimer)
    {
    __ASSERT_DEBUG((aUserAgent && aTimer) || (!aUserAgent && !aTimer),
    	User::Panic(_L("TRestoreUaState::TRestoreUaState() UA/timer mismatch"),
    	KErrArgument));
    }

// -----------------------------------------------------------------------------
// TRestoreUaState::CleanupItem
// -----------------------------------------------------------------------------
//
TCleanupItem TRestoreUaState::CleanupItem()
    {
    return TCleanupItem(Restore, this);
    }

// -----------------------------------------------------------------------------
// TRestoreUaState::Restore
// -----------------------------------------------------------------------------
//
void TRestoreUaState::Restore(TAny* aRestoreState)
    {
	__SIP_ASSERT_RETURN(aRestoreState, KErrArgument);

    TRestoreUaState* restore =
    	reinterpret_cast<TRestoreUaState*>(aRestoreState);

	restore->iFinalRespPassed = restore->iOriginalValue;

	if (restore->iUserAgent && restore->iTimer)
    	{
    	restore->iUserAgent->DeleteTimer(*restore->iTimer);
        }
	}