os/security/authorisation/userpromptservice/database/source/upsdbcompact.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 * Implements an interface to perform asynchronous database operations.
    16 *
    17 */
    18 
    19 
    20 /**
    21  @file
    22  @internalTechnology
    23  @released
    24 */
    25  
    26 #include "upsdbw.h"
    27 
    28 using namespace UserPromptService;
    29 
    30 
    31 CDecisionDbCompactor::CDecisionDbCompactor():CActive(EPriorityStandard)
    32 /**
    33 	Constructor. 
    34  */
    35 	{
    36 	CActiveScheduler::Add(this);
    37 	}
    38 	
    39 CDecisionDbCompactor::~CDecisionDbCompactor()
    40 /**
    41 	Destructor
    42  */
    43  	{
    44  	iDbIncremental.Close();
    45  	Deque();
    46  	}
    47  	
    48  CDecisionDbCompactor* CDecisionDbCompactor::NewLC()
    49  /**
    50 	
    51 	
    52 	@return A pointer to the newly allocated compactor object, if creation is successful.
    53 	        The pointer is also put onto the cleanup stack.
    54  */
    55  	{
    56  	CDecisionDbCompactor *self = new(ELeave) CDecisionDbCompactor();
    57  	CleanupStack::PushL(self);
    58  	return self;
    59  	}
    60  	
    61  
    62  EXPORT_C void CDecisionDbCompactor::Compact(TRequestStatus& aStatus)
    63  /**
    64  	Performs the asynchronous compaction of the decision database, returning immediately 
    65  	and signalling the request status when the operation is fully complete.
    66  	
    67  	@param aStatus The request status used to contain completion information for the function.
    68 	               On completion, the status value should be interpreted as follows: 
    69 	               0, compaction is complete.< 0, an error code.
    70  	
    71   */
    72  	{
    73 	__ASSERT_ALWAYS(!IsActive(), User::Panic(KDecisionViewPanic,KErrInUse));	
    74 	
    75 	aStatus = KRequestPending;
    76 	iClientStatus = &aStatus;
    77 		
    78 	if(iStep() > 0)
    79 		{	
    80 	    iDbIncremental.Next(iStep, iStatus);
    81 		SetActive();
    82 		}
    83 	else
    84 		{
    85 		iDbIncremental.Close();
    86 		User::RequestComplete(iClientStatus,KErrNone);
    87 		}
    88 	
    89 	}
    90 	
    91 
    92 void CDecisionDbCompactor::DoCancel()
    93 //From CActive
    94 	{
    95 	iDbIncremental.Close();
    96 	if (iClientStatus)
    97 		{
    98 		User::RequestComplete(iClientStatus, KErrCancel);
    99 		}
   100 	}
   101 
   102 
   103 TInt CDecisionDbCompactor::RunError(TInt aError)
   104 //From CActive
   105 	{
   106 	if (iClientStatus)
   107 		{
   108 		User::RequestComplete(iClientStatus, aError);
   109 		}
   110 	return KErrNone;
   111 	}
   112 
   113 
   114 void CDecisionDbCompactor::RunL() 
   115 //From CActive
   116 	{
   117 	TInt status = iStatus.Int();
   118 	User::LeaveIfError(status);
   119 	
   120 	if(iStep() > 0)
   121 		{
   122 		iDbIncremental.Next(iStep, iStatus);
   123 		SetActive();
   124 		}
   125 	else
   126 		{
   127 		iDbIncremental.Close();
   128 		User::RequestComplete(iClientStatus,status);
   129 		}
   130 	}