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