sl@0: /* sl@0: * Copyright (c) 2005-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: /** sl@0: @file sl@0: */ sl@0: sl@0: #include "t_unifiedcertstoreactiongetcert.h" sl@0: #include "t_input.h" sl@0: #include "t_certstoredefs.h" sl@0: #include "t_certstoreout.h" sl@0: sl@0: CTestAction* CUnifiedCertStoreGetCert::NewL(RFs& aFs, CConsoleBase& aConsole, sl@0: Output& aOut, sl@0: const TTestActionSpec& aTestActionSpec) sl@0: sl@0: { sl@0: CUnifiedCertStoreGetCert* self = new(ELeave) CUnifiedCertStoreGetCert(aFs, aConsole, aOut); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aTestActionSpec); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: sl@0: CUnifiedCertStoreGetCert::~CUnifiedCertStoreGetCert() sl@0: { sl@0: if (iCertInfo) sl@0: iCertInfo->Release(); sl@0: } sl@0: sl@0: CUnifiedCertStoreGetCert::CUnifiedCertStoreGetCert(RFs& aFs, CConsoleBase& aConsole, sl@0: Output& aOut) sl@0: : CCertStoreTestAction(aFs, aConsole, aOut), sl@0: iState(EGetCert) sl@0: { sl@0: } sl@0: sl@0: void CUnifiedCertStoreGetCert::ConstructL(const TTestActionSpec& aTestActionSpec) sl@0: { sl@0: CCertStoreTestAction::ConstructL(aTestActionSpec); sl@0: TInt pos = 0; sl@0: TInt err = KErrNone; sl@0: TLex8 lex(Input::ParseElement(aTestActionSpec.iActionBody, KTokenTypeStart, KTokenTypeEnd, pos, err)); sl@0: if (err != KErrNone) sl@0: { sl@0: User::Leave(err); sl@0: } sl@0: TUid uid; sl@0: lex.Val(uid.iUid); // check for error sl@0: sl@0: TInt token; sl@0: lex = TLex8(Input::ParseElement(aTestActionSpec.iActionBody, KTokenStart, KTokenEnd, pos, err)); sl@0: lex.Val(token); sl@0: sl@0: TInt object; sl@0: lex = TLex8(Input::ParseElement(aTestActionSpec.iActionBody, KObjectStart, KObjectEnd, pos, err)); sl@0: lex.Val(object); sl@0: sl@0: iHandle = TCTTokenObjectHandle(TCTTokenHandle(uid, token), object); sl@0: sl@0: pos = 0; sl@0: sl@0: HBufC* result = HBufC::NewLC(aTestActionSpec.iActionResult.Length()); sl@0: TPtr(result->Des()).Copy(aTestActionSpec.iActionResult); sl@0: Input::GetExpectedResultL(Input::ParseElement(*result, KReturnStart, KReturnEnd), iExpectedResult); sl@0: CleanupStack::PopAndDestroy(result); sl@0: } sl@0: sl@0: void CUnifiedCertStoreGetCert::PerformAction(TRequestStatus& aStatus) sl@0: { sl@0: switch (iState) sl@0: { sl@0: case EGetCert: sl@0: CertStore().GetCert(iCertInfo, iHandle, aStatus); sl@0: iState = EFinished; sl@0: break; sl@0: sl@0: case EFinished: sl@0: { sl@0: if (aStatus == iExpectedResult) sl@0: { sl@0: iResult = ETrue; sl@0: } sl@0: else sl@0: { sl@0: iResult = EFalse; sl@0: } sl@0: iFinished = ETrue; sl@0: TRequestStatus* status = &aStatus; sl@0: User::RequestComplete(status, KErrNone); sl@0: break; sl@0: } sl@0: sl@0: // The initial state is set to EGetCert and the default case would sl@0: // never be reached. sl@0: default: sl@0: iResult = EFalse; sl@0: iFinished = ETrue; sl@0: TRequestStatus* status = &aStatus; sl@0: User::RequestComplete(status, KErrNotSupported); sl@0: break; sl@0: } sl@0: } sl@0: sl@0: void CUnifiedCertStoreGetCert::PerformCancel() sl@0: { sl@0: } sl@0: sl@0: void CUnifiedCertStoreGetCert::Reset() sl@0: { sl@0: __ASSERT_DEBUG(EFalse, User::Panic(_L("CUnifiedCertStoreGetCert::Reset()"), 1)); sl@0: } sl@0: sl@0: void CUnifiedCertStoreGetCert::DoReportAction() sl@0: { sl@0: //iOut.writeString(_L("Setting trust settings...")); sl@0: iOut.writeHex(iHandle.iTokenHandle.iTokenTypeUid.iUid); sl@0: //iOut.writeNewLine(); sl@0: //iOut.writeString(_L("\tLabel = ")); sl@0: // iOut.writeString(iLabel); sl@0: // iOut.writeNewLine(); sl@0: //iOut.writeString(_L("\tTrusters = ")); sl@0: //TInt count = iTrusters->Count(); sl@0: //for (TInt i = 0; i < count; i++) sl@0: // { sl@0: // iOut.writeNum((*iTrusters)[i].iUid); sl@0: // iOut.writeString(_L(" ")); sl@0: // } sl@0: //iOut.writeNewLine(); sl@0: //iOut.writeNewLine(); sl@0: } sl@0: sl@0: void CUnifiedCertStoreGetCert::DoCheckResult(TInt /*aError*/) sl@0: { sl@0: }