multimediacommsengine/tsrc/MCETestUI/MCETestUIEngine/src/TMCETestUIEngineCmdCryptoHandling.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2005 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 "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:    Implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDES
       
    22 
       
    23 #include "TMCETestUIEngineCmdCryptoHandling.h"
       
    24 #include "CMCETestUIEngineSession.h"
       
    25 #include "CMCETestUIEngineOutSession.h"
       
    26 #include "CMCETestUIQuestionSingleSelection.h"
       
    27 #include <mcesecureoutsession.h>
       
    28 #include <mcesecureinsession.h>
       
    29 #include <mcesecuresession.h>
       
    30 
       
    31 
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // TMCETestUIEngineCmdCurrentCryptoContext::TMCETestUIEngineCmdCurrentCryptoContext
       
    35 // -----------------------------------------------------------------------------
       
    36 //
       
    37 TMCETestUIEngineCmdCurrentCryptoContext::TMCETestUIEngineCmdCurrentCryptoContext(
       
    38 		            CMCETestUIEngine& aEngine,
       
    39 		            CMCETestUIEngineSession& aSession )
       
    40     : TMCETestUIEngineCmdBase( aEngine ),
       
    41       iSession( aSession )
       
    42     {
       
    43     }
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // TMCETestUIEngineCmdCurrentCryptoContext::ExecuteL
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 EXPORT_C void TMCETestUIEngineCmdCurrentCryptoContext::ExecuteL()
       
    50 	{
       
    51 	RArray<TMceCryptoContext> currentCryptoContexts ;
       
    52 	if(iSession.iType == KMceOutSession)
       
    53 		{
       
    54 		CMceSecureOutSession& outSecSession = static_cast<CMceSecureOutSession&>(iSession.Session());		
       
    55 		currentCryptoContexts = outSecSession.CryptoContexts();
       
    56 		}
       
    57 	else
       
    58 		{
       
    59 		CMceSecureInSession& inSecSession = static_cast<CMceSecureInSession&>(iSession.Session());
       
    60 		currentCryptoContexts = inSecSession.CryptoContexts();
       
    61 		}
       
    62 	TBool crypto32 = EFalse;
       
    63 	TBool crypto80 = EFalse;
       
    64 	for(TInt i = 0; i< currentCryptoContexts.Count(); i++)
       
    65 		{
       
    66 		if(currentCryptoContexts[i] == EAES_CM_128_HMAC_SHA1_32 )
       
    67 			{
       
    68 			crypto32 = ETrue;
       
    69 			}
       
    70 		else if(currentCryptoContexts[i] == EAES_CM_128_HMAC_SHA1_80 )
       
    71 			{
       
    72 			crypto80 = ETrue;
       
    73 			}
       
    74 		}
       
    75 	iEngine.ShowCurrentCryptoContextsL(crypto32,crypto80);
       
    76 	}
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // TMCETestUIEngineCmdCurrentCryptoContext::Caption
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 EXPORT_C const TDesC& TMCETestUIEngineCmdCurrentCryptoContext::Caption() const
       
    83 	{
       
    84 	return KCommandCaptionCurrentCryptoContext;
       
    85 	}
       
    86 
       
    87 // -----------------------------------------------------------------------------
       
    88 // TMCETestUIEngineCmdSupportedCryptoContext::TMCETestUIEngineCmdSupportedCryptoContext
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 TMCETestUIEngineCmdSupportedCryptoContext::TMCETestUIEngineCmdSupportedCryptoContext(
       
    92 		            CMCETestUIEngine& aEngine,
       
    93 		            CMCETestUIEngineSession& aSession )
       
    94     : TMCETestUIEngineCmdBase( aEngine ),
       
    95       iSession( aSession )
       
    96     {
       
    97     }
       
    98 
       
    99 // -----------------------------------------------------------------------------
       
   100 // TMCETestUIEngineCmdSupportedCryptoContext::ExecuteL
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 EXPORT_C void TMCETestUIEngineCmdSupportedCryptoContext::ExecuteL()
       
   104 	{
       
   105 	RArray<TMceCryptoContext> currentCryptoContexts ;
       
   106 	if(iSession.iType == KMceOutSession)
       
   107 		{
       
   108 		CMceSecureOutSession& outSecSession = static_cast<CMceSecureOutSession&>(iSession.Session());		
       
   109 		currentCryptoContexts = outSecSession.SupportedCryptoContextsL();
       
   110 		}
       
   111 	else
       
   112 		{
       
   113 		CMceSecureInSession& inSecSession = static_cast<CMceSecureInSession&>(iSession.Session());
       
   114 		currentCryptoContexts = inSecSession.SupportedCryptoContextsL();
       
   115 		}
       
   116 	TBool crypto32 = EFalse;
       
   117 	TBool crypto80 = EFalse;
       
   118 	for(TInt i = 0; i< currentCryptoContexts.Count(); i++)
       
   119 		{
       
   120 		if(currentCryptoContexts[i] == EAES_CM_128_HMAC_SHA1_32 )
       
   121 			{
       
   122 			crypto32 = ETrue;
       
   123 			}
       
   124 		else if(currentCryptoContexts[i] == EAES_CM_128_HMAC_SHA1_80 )
       
   125 			{
       
   126 			crypto80 = ETrue;
       
   127 			}
       
   128 		}
       
   129 	iEngine.ShowSupportedCryptoContextsL(crypto32,crypto80);
       
   130 	}
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // TMCETestUIEngineCmdSupportedCryptoContext::Caption
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 EXPORT_C const TDesC& TMCETestUIEngineCmdSupportedCryptoContext::Caption() const
       
   137 	{
       
   138 	return KCommandCaptionSupportedCryptoContext;
       
   139 	}
       
   140 // -----------------------------------------------------------------------------
       
   141 // TMCETestUIEngineCmdSetCryptoContext::TMCETestUIEngineCmdSetCryptoContext
       
   142 // -----------------------------------------------------------------------------
       
   143 //
       
   144 TMCETestUIEngineCmdSetCryptoContext::TMCETestUIEngineCmdSetCryptoContext(
       
   145 		            CMCETestUIEngine& aEngine,
       
   146 		            CMCETestUIEngineSession& aSession )
       
   147     : TMCETestUIEngineCmdBase( aEngine ),
       
   148       iSession( aSession )
       
   149     {
       
   150     }
       
   151 
       
   152 // -----------------------------------------------------------------------------
       
   153 // TMCETestUIEngineCmdSetCryptoContext::ExecuteL
       
   154 // -----------------------------------------------------------------------------
       
   155 //
       
   156 EXPORT_C void TMCETestUIEngineCmdSetCryptoContext::ExecuteL()
       
   157 	{
       
   158 	RArray<TMceCryptoContext> currentCryptoContexts ;
       
   159 	TBool crypto32 = EFalse;
       
   160 	TBool crypto80 = EFalse;
       
   161 	iEngine.GetCryptoContextsL(crypto32,crypto80);
       
   162     if(crypto32)
       
   163     	{
       
   164     	currentCryptoContexts.Append(EAES_CM_128_HMAC_SHA1_32);
       
   165     	}
       
   166    	if(crypto80) 	
       
   167    		{
       
   168    		currentCryptoContexts.Append(EAES_CM_128_HMAC_SHA1_80);
       
   169    		}
       
   170    		
       
   171    	if(iSession.iType == KMceOutSession)
       
   172 		{
       
   173 		CMceSecureOutSession& outSecSession = static_cast<CMceSecureOutSession&>(iSession.Session());		
       
   174 		outSecSession.SetCryptoContextsL(currentCryptoContexts);
       
   175 		}
       
   176 	else
       
   177 		{
       
   178 		CMceSecureInSession& inSecSession = static_cast<CMceSecureInSession&>(iSession.Session());
       
   179 		inSecSession.SetCryptoContextsL(currentCryptoContexts);
       
   180 		}
       
   181 	}
       
   182 
       
   183 // -----------------------------------------------------------------------------
       
   184 // TMCETestUIEngineCmdSetCryptoContext::Caption
       
   185 // -----------------------------------------------------------------------------
       
   186 //
       
   187 EXPORT_C const TDesC& TMCETestUIEngineCmdSetCryptoContext::Caption() const
       
   188 	{
       
   189 	return KCommandCaptionSetCryptoContext;
       
   190 	}
       
   191 
       
   192 // End of File