sl@0: /* sl@0: * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * Implements an interface to perform asynchronous database operations. sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @internalTechnology sl@0: @released sl@0: */ sl@0: sl@0: #include "upsdbw.h" sl@0: sl@0: using namespace UserPromptService; sl@0: sl@0: sl@0: CDecisionDbCompactor::CDecisionDbCompactor():CActive(EPriorityStandard) sl@0: /** sl@0: Constructor. sl@0: */ sl@0: { sl@0: CActiveScheduler::Add(this); sl@0: } sl@0: sl@0: CDecisionDbCompactor::~CDecisionDbCompactor() sl@0: /** sl@0: Destructor sl@0: */ sl@0: { sl@0: iDbIncremental.Close(); sl@0: Deque(); sl@0: } sl@0: sl@0: CDecisionDbCompactor* CDecisionDbCompactor::NewLC() sl@0: /** sl@0: sl@0: sl@0: @return A pointer to the newly allocated compactor object, if creation is successful. sl@0: The pointer is also put onto the cleanup stack. sl@0: */ sl@0: { sl@0: CDecisionDbCompactor *self = new(ELeave) CDecisionDbCompactor(); sl@0: CleanupStack::PushL(self); sl@0: return self; sl@0: } sl@0: sl@0: sl@0: EXPORT_C void CDecisionDbCompactor::Compact(TRequestStatus& aStatus) sl@0: /** sl@0: Performs the asynchronous compaction of the decision database, returning immediately sl@0: and signalling the request status when the operation is fully complete. sl@0: sl@0: @param aStatus The request status used to contain completion information for the function. sl@0: On completion, the status value should be interpreted as follows: sl@0: 0, compaction is complete.< 0, an error code. sl@0: sl@0: */ sl@0: { sl@0: __ASSERT_ALWAYS(!IsActive(), User::Panic(KDecisionViewPanic,KErrInUse)); sl@0: sl@0: aStatus = KRequestPending; sl@0: iClientStatus = &aStatus; sl@0: sl@0: if(iStep() > 0) sl@0: { sl@0: iDbIncremental.Next(iStep, iStatus); sl@0: SetActive(); sl@0: } sl@0: else sl@0: { sl@0: iDbIncremental.Close(); sl@0: User::RequestComplete(iClientStatus,KErrNone); sl@0: } sl@0: sl@0: } sl@0: sl@0: sl@0: void CDecisionDbCompactor::DoCancel() sl@0: //From CActive sl@0: { sl@0: iDbIncremental.Close(); sl@0: if (iClientStatus) sl@0: { sl@0: User::RequestComplete(iClientStatus, KErrCancel); sl@0: } sl@0: } sl@0: sl@0: sl@0: TInt CDecisionDbCompactor::RunError(TInt aError) sl@0: //From CActive sl@0: { sl@0: if (iClientStatus) sl@0: { sl@0: User::RequestComplete(iClientStatus, aError); sl@0: } sl@0: return KErrNone; sl@0: } sl@0: sl@0: sl@0: void CDecisionDbCompactor::RunL() sl@0: //From CActive sl@0: { sl@0: TInt status = iStatus.Int(); sl@0: User::LeaveIfError(status); sl@0: sl@0: if(iStep() > 0) sl@0: { sl@0: iDbIncremental.Next(iStep, iStatus); sl@0: SetActive(); sl@0: } sl@0: else sl@0: { sl@0: iDbIncremental.Close(); sl@0: User::RequestComplete(iClientStatus,status); sl@0: } sl@0: }