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 sl@0: #include sl@0: #include sl@0: sl@0: #include "certtool_controller.h" sl@0: sl@0: sl@0: _LIT(KCertToolResources,"Z:\\Resource\\Apps\\keytool.RSC"); sl@0: sl@0: CCertToolController::CCertToolController(MKeyToolView& aView) : CController(aView) sl@0: { sl@0: } sl@0: sl@0: CCertToolController::~CCertToolController() sl@0: { sl@0: delete iEngine; sl@0: } sl@0: sl@0: /*static*/ CCertToolController* CCertToolController::NewLC(MKeyToolView& aView) sl@0: { sl@0: CCertToolController* self = new (ELeave) CCertToolController(aView); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: return self; sl@0: } sl@0: sl@0: void CCertToolController::ConstructL() sl@0: { sl@0: User::LeaveIfError(iFsSession.Connect()); // Connect session sl@0: sl@0: TFileName fileName(KCertToolResources); sl@0: sl@0: // open file, leave if error sl@0: iResourceFile.OpenL(iFsSession, fileName); sl@0: sl@0: iResourceFile.ConfirmSignatureL(); sl@0: sl@0: iEngine = CCertToolEngine::NewL(this); sl@0: } sl@0: sl@0: void CCertToolController::HandleCommandL(TInt aCommand, CKeyToolParameters* aParam) sl@0: { sl@0: TInt certstoreIndex = -1; sl@0: switch (aCommand) sl@0: { sl@0: case KUsageCommand: sl@0: { sl@0: iEngine->DisplayUsageL(aParam); sl@0: } sl@0: break; sl@0: case KListCommand: sl@0: { sl@0: iEngine->ListL(aParam); sl@0: CActiveScheduler::Start(); sl@0: } sl@0: break; sl@0: case KImportCommand: sl@0: { sl@0: if (aParam->iPrivate) sl@0: { sl@0: CKeyToolParameters* parm = CKeyToolParameters::NewLC(); sl@0: parm->iDefault = aParam->iPrivate->AllocL(); sl@0: if(aParam->iLabel) sl@0: { sl@0: parm->iLabel = aParam->iLabel->AllocL(); sl@0: } sl@0: else sl@0: { sl@0: parm->iLabel = aParam->iDefault->AllocL(); sl@0: } sl@0: iEngine->ImportPrivateL(parm); sl@0: CActiveScheduler::Start(); sl@0: delete parm->iDefault; sl@0: parm->iDefault = NULL; sl@0: if(aParam->iLabel) sl@0: { sl@0: parm->iDefault = aParam->iLabel->AllocL(); sl@0: } sl@0: else sl@0: { sl@0: parm->iDefault = aParam->iDefault->AllocL(); sl@0: } sl@0: parm->iPolicy = CKeyToolParameters::ESetManagerPolicy; sl@0: iEngine->SetManagerPolicyL(parm); sl@0: CActiveScheduler::Start(); sl@0: CleanupStack::PopAndDestroy(parm); sl@0: } sl@0: iEngine->ImportL(aParam); sl@0: CActiveScheduler::Start(); sl@0: if (aParam->iLabel) sl@0: { sl@0: delete aParam->iDefault; sl@0: aParam->iDefault = NULL; sl@0: aParam->iDefault = aParam->iLabel->AllocL(); sl@0: } sl@0: iEngine->ListL(aParam); sl@0: CActiveScheduler::Start(); sl@0: } sl@0: break; sl@0: case KRemoveCommand: sl@0: { sl@0: if (aParam->iRemoveKey) sl@0: { sl@0: CKeyToolParameters* parm = CKeyToolParameters::NewLC(); sl@0: parm->iDefault = aParam->iDefault->AllocL(); sl@0: iEngine->RemovePrivateL(parm); sl@0: CActiveScheduler::Start(); sl@0: CleanupStack::PopAndDestroy(parm); sl@0: } sl@0: iEngine->RemoveL(aParam); sl@0: CActiveScheduler::Start(); sl@0: } sl@0: break; sl@0: case KSetAppsCommand: sl@0: { sl@0: certstoreIndex = aParam->iCertstoreIndex; sl@0: iEngine->SetAppsL(aParam); sl@0: if (aParam->iLabel) sl@0: { sl@0: delete aParam->iDefault; sl@0: aParam->iDefault = NULL; sl@0: aParam->iDefault = aParam->iLabel->AllocL(); sl@0: } sl@0: CActiveScheduler::Start(); sl@0: aParam->iCertstoreIndex = certstoreIndex; sl@0: iEngine->ListL(aParam); sl@0: CActiveScheduler::Start(); sl@0: } sl@0: break; sl@0: case KListStoresCommand: sl@0: { sl@0: iEngine->ListStoresL(aParam); sl@0: CActiveScheduler::Start(); sl@0: } sl@0: break; sl@0: case KAddAppsCommand: sl@0: { sl@0: certstoreIndex = aParam->iCertstoreIndex; sl@0: iEngine->AddAppsL(aParam); sl@0: if (aParam->iLabel) sl@0: { sl@0: delete aParam->iDefault; sl@0: aParam->iDefault = NULL; sl@0: aParam->iDefault = aParam->iLabel->AllocL(); sl@0: } sl@0: CActiveScheduler::Start(); sl@0: aParam->iCertstoreIndex = certstoreIndex; sl@0: iEngine->ListL(aParam); sl@0: CActiveScheduler::Start(); sl@0: } sl@0: break; sl@0: case KRemoveAppsCommand: sl@0: { sl@0: certstoreIndex = aParam->iCertstoreIndex; sl@0: iEngine->RemoveAppsL(aParam); sl@0: CActiveScheduler::Start(); sl@0: aParam->iCertstoreIndex = certstoreIndex; sl@0: iEngine->ListL(aParam); sl@0: CActiveScheduler::Start(); sl@0: } sl@0: break; sl@0: default: sl@0: { sl@0: DisplayLocalisedMsgL(R_CERTTOOL_ERR_COMMAND); sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: } sl@0: }