os/security/authorisation/userpromptservice/database/source/upsdbcompact.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/authorisation/userpromptservice/database/source/upsdbcompact.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,130 @@
     1.4 +/*
     1.5 +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +* Implements an interface to perform asynchronous database operations.
    1.19 +*
    1.20 +*/
    1.21 +
    1.22 +
    1.23 +/**
    1.24 + @file
    1.25 + @internalTechnology
    1.26 + @released
    1.27 +*/
    1.28 + 
    1.29 +#include "upsdbw.h"
    1.30 +
    1.31 +using namespace UserPromptService;
    1.32 +
    1.33 +
    1.34 +CDecisionDbCompactor::CDecisionDbCompactor():CActive(EPriorityStandard)
    1.35 +/**
    1.36 +	Constructor. 
    1.37 + */
    1.38 +	{
    1.39 +	CActiveScheduler::Add(this);
    1.40 +	}
    1.41 +	
    1.42 +CDecisionDbCompactor::~CDecisionDbCompactor()
    1.43 +/**
    1.44 +	Destructor
    1.45 + */
    1.46 + 	{
    1.47 + 	iDbIncremental.Close();
    1.48 + 	Deque();
    1.49 + 	}
    1.50 + 	
    1.51 + CDecisionDbCompactor* CDecisionDbCompactor::NewLC()
    1.52 + /**
    1.53 +	
    1.54 +	
    1.55 +	@return A pointer to the newly allocated compactor object, if creation is successful.
    1.56 +	        The pointer is also put onto the cleanup stack.
    1.57 + */
    1.58 + 	{
    1.59 + 	CDecisionDbCompactor *self = new(ELeave) CDecisionDbCompactor();
    1.60 + 	CleanupStack::PushL(self);
    1.61 + 	return self;
    1.62 + 	}
    1.63 + 	
    1.64 + 
    1.65 + EXPORT_C void CDecisionDbCompactor::Compact(TRequestStatus& aStatus)
    1.66 + /**
    1.67 + 	Performs the asynchronous compaction of the decision database, returning immediately 
    1.68 + 	and signalling the request status when the operation is fully complete.
    1.69 + 	
    1.70 + 	@param aStatus The request status used to contain completion information for the function.
    1.71 +	               On completion, the status value should be interpreted as follows: 
    1.72 +	               0, compaction is complete.< 0, an error code.
    1.73 + 	
    1.74 +  */
    1.75 + 	{
    1.76 +	__ASSERT_ALWAYS(!IsActive(), User::Panic(KDecisionViewPanic,KErrInUse));	
    1.77 +	
    1.78 +	aStatus = KRequestPending;
    1.79 +	iClientStatus = &aStatus;
    1.80 +		
    1.81 +	if(iStep() > 0)
    1.82 +		{	
    1.83 +	    iDbIncremental.Next(iStep, iStatus);
    1.84 +		SetActive();
    1.85 +		}
    1.86 +	else
    1.87 +		{
    1.88 +		iDbIncremental.Close();
    1.89 +		User::RequestComplete(iClientStatus,KErrNone);
    1.90 +		}
    1.91 +	
    1.92 +	}
    1.93 +	
    1.94 +
    1.95 +void CDecisionDbCompactor::DoCancel()
    1.96 +//From CActive
    1.97 +	{
    1.98 +	iDbIncremental.Close();
    1.99 +	if (iClientStatus)
   1.100 +		{
   1.101 +		User::RequestComplete(iClientStatus, KErrCancel);
   1.102 +		}
   1.103 +	}
   1.104 +
   1.105 +
   1.106 +TInt CDecisionDbCompactor::RunError(TInt aError)
   1.107 +//From CActive
   1.108 +	{
   1.109 +	if (iClientStatus)
   1.110 +		{
   1.111 +		User::RequestComplete(iClientStatus, aError);
   1.112 +		}
   1.113 +	return KErrNone;
   1.114 +	}
   1.115 +
   1.116 +
   1.117 +void CDecisionDbCompactor::RunL() 
   1.118 +//From CActive
   1.119 +	{
   1.120 +	TInt status = iStatus.Int();
   1.121 +	User::LeaveIfError(status);
   1.122 +	
   1.123 +	if(iStep() > 0)
   1.124 +		{
   1.125 +		iDbIncremental.Next(iStep, iStatus);
   1.126 +		SetActive();
   1.127 +		}
   1.128 +	else
   1.129 +		{
   1.130 +		iDbIncremental.Close();
   1.131 +		User::RequestComplete(iClientStatus,status);
   1.132 +		}
   1.133 +	}