cryptoservices/certificateandkeymgmt/tcertstore/T_ccttokentypeinfoattributes.cpp
changeset 0 2c201484c85f
child 8 35751d3474b7
equal deleted inserted replaced
-1:000000000000 0:2c201484c85f
       
     1 /*
       
     2 * Copyright (c) 2005-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 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 /**
       
    22  @file
       
    23 */
       
    24 
       
    25 #include "t_ccttokentypeinfoattributes.h"
       
    26 #include "t_certstoreout.h"
       
    27 #include "t_certstoredefs.h"
       
    28 #include "t_input.h"
       
    29 #include <mctcertstore.h>
       
    30 
       
    31 CTestAction* CCTTokenTypeInfoAttributes::NewL(RFs& aFs, 
       
    32 															 CConsoleBase& aConsole,
       
    33 															 Output& aOut,
       
    34 															 const TTestActionSpec& aTestActionSpec)
       
    35 	{
       
    36 	CCTTokenTypeInfoAttributes* self = new(ELeave) CCTTokenTypeInfoAttributes(aFs, aConsole, aOut);
       
    37 	CleanupStack::PushL(self);
       
    38 	self->ConstructL(aTestActionSpec);
       
    39 	CleanupStack::Pop(self);
       
    40 	return self;
       
    41 	}
       
    42 
       
    43 
       
    44 CCTTokenTypeInfoAttributes::~CCTTokenTypeInfoAttributes()
       
    45 	{
       
    46 	iTokenTypes.Close();
       
    47 	}
       
    48 
       
    49 CCTTokenTypeInfoAttributes::CCTTokenTypeInfoAttributes(RFs& aFs, CConsoleBase& aConsole,
       
    50 													   Output& aOut)
       
    51 : CCertStoreTestAction(aFs, aConsole, aOut), iState(EFinished)
       
    52 	{
       
    53 	}
       
    54 
       
    55 void CCTTokenTypeInfoAttributes::ConstructL(const TTestActionSpec& aTestActionSpec)
       
    56 	{
       
    57 	CCertStoreTestAction::ConstructL(aTestActionSpec);
       
    58 		
       
    59 	HBufC* result = HBufC::NewLC(aTestActionSpec.iActionResult.Length());
       
    60 	TPtr(result->Des()).Copy(aTestActionSpec.iActionResult);
       
    61 	Input::GetExpectedResultL(Input::ParseElement(*result, KReturnStart, KReturnEnd), iExpectedResult);
       
    62 	CleanupStack::PopAndDestroy(result);
       
    63 	
       
    64 	}
       
    65 
       
    66 void CCTTokenTypeInfoAttributes::PerformAction(TRequestStatus& aStatus)
       
    67 	{
       
    68 	switch (iState)
       
    69 		{
       
    70 		case EFinished:
       
    71 			{
       
    72 			RArray<TUid> uidArray;
       
    73 			CleanupClosePushL(uidArray);
       
    74 			TUid uid1 = { KInterfaceCertStore };
       
    75 				
       
    76 			uidArray.Append(uid1);
       
    77 			TCTFindTokenTypesByInterface filter(uidArray.Array());
       
    78 			CCTTokenTypeInfo::ListL(iTokenTypes, filter);
       
    79 
       
    80 			CleanupStack::PopAndDestroy();	// uidArray
       
    81 			
       
    82 			TRequestStatus* status = &aStatus;
       
    83 			User::RequestComplete(status, aStatus.Int());
       
    84 			if (aStatus == iExpectedResult)
       
    85 				{
       
    86 				iResult = ETrue;
       
    87 				}
       
    88 			else
       
    89 				{
       
    90 				iResult = EFalse;
       
    91 				}
       
    92 			if (aStatus == KErrNoMemory)
       
    93 				{	
       
    94 			//	iState = EDelete;
       
    95 				}
       
    96 			else
       
    97 				{
       
    98 				iFinished = ETrue;
       
    99 				}
       
   100 			}
       
   101 			break;
       
   102 		}
       
   103 	}
       
   104 
       
   105 void CCTTokenTypeInfoAttributes::PerformCancel()
       
   106 	{
       
   107 	}
       
   108 
       
   109 void CCTTokenTypeInfoAttributes::Reset()
       
   110 	{
       
   111 	iTokenTypes.Close();
       
   112 	}
       
   113 
       
   114 void CCTTokenTypeInfoAttributes::DoPerformPrerequisite(TRequestStatus& aStatus)
       
   115 	{
       
   116 	iExpectedResult = KErrNone;
       
   117 	iActionState = EAction;
       
   118 	TRequestStatus* status = &aStatus;
       
   119 	User::RequestComplete(status, KErrNone);
       
   120 	}
       
   121 
       
   122 void CCTTokenTypeInfoAttributes::DoPerformPostrequisite(TRequestStatus& aStatus)
       
   123 	{
       
   124 	TRequestStatus* status = &aStatus;
       
   125 	User::RequestComplete(status, KErrNone);
       
   126 	}
       
   127 
       
   128 void CCTTokenTypeInfoAttributes::DoReportAction()
       
   129 	{
       
   130 	iOut.writeString(_L("Listing Unified Cert Store..."));
       
   131 	iOut.writeNewLine();
       
   132 	}
       
   133 
       
   134 void CCTTokenTypeInfoAttributes::DoCheckResult(TInt /*aError*/)
       
   135 	{
       
   136 	TInt i = 0;
       
   137 	TInt end = iTokenTypes.Count();
       
   138 	while (i < end)
       
   139 		{
       
   140 		iOut.writeString(iTokenTypes[i]->Label());
       
   141 		iOut.writeNewLine();
       
   142 		const RArray<TCTTokenTypeAttribute>& attributes = iTokenTypes[i]->Attributes();
       
   143 		int j = 0;
       
   144 		int jEnd = attributes.Count();
       
   145 		while (j < jEnd)
       
   146 			{
       
   147 			iOut.writeString(_L("UID:"));
       
   148 			iOut.writeHex(attributes[j].iUID.iUid);
       
   149 			iOut.writeString(_L(" "));
       
   150 			iOut.writeString(_L("Attribute:"));
       
   151 			iOut.writeNum(attributes[j].iVal);
       
   152 			iOut.writeNewLine();
       
   153 			j++;
       
   154 			}
       
   155 		i++;
       
   156 		}
       
   157 	}