sl@0: /* sl@0: * Copyright (c) 2004-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: * sl@0: */ sl@0: sl@0: sl@0: #include "certtool_commands.h" sl@0: #include "certtool_controller.h" sl@0: sl@0: /*static*/ CCertToolRemove* CCertToolRemove::NewLC(CCertToolController* aController) sl@0: { sl@0: CCertToolRemove* self = new (ELeave) CCertToolRemove(aController); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: return self; sl@0: } sl@0: sl@0: /*static*/ CCertToolRemove* CCertToolRemove::NewL(CCertToolController* aController) sl@0: { sl@0: CCertToolRemove* self = CCertToolRemove::NewLC(aController); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: CCertToolRemove::CCertToolRemove(CCertToolController* aController) : CCertToolList(aController) sl@0: { sl@0: sl@0: } sl@0: sl@0: CCertToolRemove::~CCertToolRemove() sl@0: { sl@0: Cancel(); sl@0: } sl@0: sl@0: void CCertToolRemove::RunL() sl@0: { sl@0: if (iStatus.Int() != KErrNone) sl@0: { sl@0: User::Leave(iStatus.Int()); sl@0: } sl@0: switch (iState) sl@0: { sl@0: case EListCerts: sl@0: { sl@0: // Look for a specific certificate sl@0: TInt certIndex = -1; sl@0: for (TInt j = 0; j < iCertInfos.Count(); j++) sl@0: { sl@0: if (iCertInfos[j]->Label() == *iParams->iDefault) sl@0: { sl@0: certIndex = j; sl@0: break; sl@0: } sl@0: } sl@0: sl@0: if (certIndex != -1) sl@0: { sl@0: iState = EFinished; sl@0: SetActive(); sl@0: iCertStore->Remove(*iCertInfos[certIndex], iStatus); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrNotFound); sl@0: } sl@0: } sl@0: break; sl@0: case EFinished: sl@0: { sl@0: sl@0: User::LeaveIfError(iStatus.Int()); sl@0: sl@0: // We are done! sl@0: iController->DisplayLocalisedMsgL(R_CERTTOOL_ERR_REMOVE_SUCCESS); sl@0: sl@0: CActiveScheduler::Stop(); sl@0: } sl@0: break; sl@0: default: sl@0: { sl@0: User::Panic(_L("REMOVE action: Illegal state."), 1); sl@0: } sl@0: } sl@0: } sl@0: sl@0: TInt CCertToolRemove::RunError(TInt aError) sl@0: { sl@0: CActiveScheduler::Stop(); sl@0: sl@0: switch (aError) sl@0: { sl@0: case KErrNotFound : sl@0: { sl@0: TRAP_IGNORE(iController->DisplayLocalisedMsgL(R_CERTTOOL_ERR_NOTFOUND)); sl@0: } sl@0: break; sl@0: default: sl@0: { sl@0: TRAP_IGNORE(iController->DisplayLocalisedMsgL(R_CERTTOOL_ERR_REMOVE_FAILURE, aError)); sl@0: } sl@0: } sl@0: sl@0: TRAP_IGNORE(iController->DisplayErrorL(_L("\n"), iParams->iPageWise)); sl@0: return KErrNone; sl@0: } sl@0: