diff -r 000000000000 -r dab8a81a92de omads/omadsappui/AspSyncUtil/src/AspState.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/omads/omadsappui/AspSyncUtil/src/AspState.cpp Mon Nov 23 14:46:41 2009 +0200 @@ -0,0 +1,271 @@ +/* +* Copyright (c) 2002-2005 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: +* +*/ + + + +// INCLUDE FILES + +#include "AspState.h" +#include "AspUtil.h" + + +// ============================ MEMBER FUNCTIONS =============================== + + +// ----------------------------------------------------------------------------- +// CAspState::NewL +// +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CAspState* CAspState::NewL() + { + CAspState* self = new (ELeave) CAspState(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + + +// ----------------------------------------------------------------------------- +// Destructor +// +// ----------------------------------------------------------------------------- +// +CAspState::~CAspState() + { + delete iSyncContent; + } + + +// ----------------------------------------------------------------------------- +// CAspState::CAspState +// +// ----------------------------------------------------------------------------- +// +CAspState::CAspState() + { + } + + +// ----------------------------------------------------------------------------- +// CAspState::ConstructL +// +// ----------------------------------------------------------------------------- +// +void CAspState::ConstructL() + { + Reset(); + + iSyncContent = HBufC::NewL(0); + } + + +// ----------------------------------------------------------------------------- +// CAspState::Reset +// +// ----------------------------------------------------------------------------- +// +void CAspState::Reset() + { + iSyncPhase = EPhaseNone; + } + + +// ----------------------------------------------------------------------------- +// CAspState::SetSyncPhase +// +// ----------------------------------------------------------------------------- +// +void CAspState::SetSyncPhase(TInt aPhase) + { + if (aPhase != iSyncPhase) + { + iSyncPhase = aPhase; + } + } + + +// ----------------------------------------------------------------------------- +// CAspState::SyncPhase +// +// ----------------------------------------------------------------------------- +// +TInt CAspState::SyncPhase() + { + return iSyncPhase; + } + + +// ----------------------------------------------------------------------------- +// CAspState::IncreaseProgress +// +// ----------------------------------------------------------------------------- +// +void CAspState::IncreaseProgress() + { + iProgressCount++; + iProgressCount2++; + } + + +// ----------------------------------------------------------------------------- +// CAspState::IncreaseProgress +// +// ----------------------------------------------------------------------------- +// +void CAspState::IncreaseProgress(TInt aCount) + { + if (aCount > 0) + { + iProgressCount = iProgressCount + aCount; + iProgressCount2++; + } + } + + +// ----------------------------------------------------------------------------- +// CAspState::Progress +// +// ----------------------------------------------------------------------------- +// +TInt CAspState::Progress() + { + return iProgressCount; + } + + +// ----------------------------------------------------------------------------- +// CAspState::SetProgress +// +// ----------------------------------------------------------------------------- +// +/* +void CAspState::SetProgress(TInt aCount) + { + if (aCount >= 0 && aCount <= KTotalProgress) + { + iProgressCount = aCount; + iProgressCount2++; + } + } +*/ + +// ----------------------------------------------------------------------------- +// CAspState::SetTotalProgress +// +// ----------------------------------------------------------------------------- +// +void CAspState::SetTotalProgress(TInt aCount) + { + if (aCount < 0) + { + iTotalProgressCount = KTotalProgressUnknown; + return; + } + + iTotalProgressCount = aCount; + } + + +// ----------------------------------------------------------------------------- +// CAspState::TotalProgress +// +// ----------------------------------------------------------------------------- +// +TInt CAspState::TotalProgress() + { + return iTotalProgressCount; + } + + +// ----------------------------------------------------------------------------- +// CAspState::FirstProgress +// +// ----------------------------------------------------------------------------- +// +TBool CAspState::FirstProgress() + { + if (iProgressCount2 == 1) + { + return ETrue; + } + + return EFalse; + } + + +// ----------------------------------------------------------------------------- +// CAspState::SetContentL +// +// ----------------------------------------------------------------------------- +// +void CAspState::SetContentL(const TDesC& aText) + { + delete iSyncContent; + iSyncContent = NULL; + iSyncContent = aText.AllocL(); + } + + +// ----------------------------------------------------------------------------- +// CAspState::Content +// +// ----------------------------------------------------------------------------- +// +const TDesC& CAspState::Content() + { + __ASSERT_ALWAYS(iSyncContent, TUtil::Panic(KErrGeneral)); + + return *iSyncContent; + } + + +// ----------------------------------------------------------------------------- +// CAspState::ResetProgress +// +// ----------------------------------------------------------------------------- +// +void CAspState::ResetProgress() + { + iProgressCount = 0; + iProgressCount2 = 0; + iTotalProgressCount = 0; + + TRAP_IGNORE(SetContentL(KNullDesC)); + } + + +// ----------------------------------------------------------------------------- +// CAspState::ProgressKnown +// +// ----------------------------------------------------------------------------- +// +TBool CAspState::ProgressKnown() + { + if (iTotalProgressCount == KTotalProgressUnknown) + { + return EFalse; + } + + return ETrue; + } + + +// End of file +