lafagnosticuifoundation/cone/src/COEMAINSECUREFEP.CPP
changeset 0 2f259fa3e83a
child 10 3d340a0166ff
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <coemain.h>
       
    17 #include "coeenvextra.h"
       
    18 #include "coepanic.h"
       
    19 #include <fepplugin.h>
       
    20 #include "COEFEP.H"
       
    21 #include "coedatastorage.h"
       
    22 
       
    23 
       
    24 #include <ecom/ecom.h>
       
    25 
       
    26 
       
    27 CCoeFepParameters* CCoeFepParameters::NewLC()
       
    28 /**
       
    29 @internalTechnology
       
    30 */
       
    31 	{
       
    32 	CCoeFepParameters* const fepParameters=new(ELeave) CCoeFepParameters;
       
    33 	CleanupStack::PushL(fepParameters);
       
    34 	return fepParameters;
       
    35 	}
       
    36 
       
    37 void CCoeEnv::EnsureSpecifiedFepIsLoadedL(TUid aFepUid)
       
    38 	{
       
    39 	if (iExtra->iFep.iFepUid != aFepUid)
       
    40 		{
       
    41 		if (aFepUid == KNullUid)
       
    42 			{
       
    43 			CCoeEnvExtra::DestroyFep(iExtra->iFep);
       
    44 			iExtra->HandleChangeInLoadedFep();
       
    45 			}
       
    46 		else
       
    47 			{
       
    48 			CCoeEnvExtra::TFep newFep;
       
    49 			CleanupStack::PushL(TCleanupItem(CCoeEnvExtra::DestroyFep, &newFep));
       
    50 			newFep.iFepPlugIn = CCoeFepPlugIn::NewL(aFepUid);
       
    51 			CCoeFepParameters* const dummyFepParameters = CCoeFepParameters::NewLC();
       
    52 			newFep.iFep = newFep.iFepPlugIn->NewFepL(*this, *dummyFepParameters);
       
    53 			CleanupStack::PopAndDestroy(dummyFepParameters);
       
    54 			newFep.iFepUid=aFepUid;
       
    55 			CleanupStack::Pop(&newFep);
       
    56 			CCoeEnvExtra::DestroyFep(iExtra->iFep);
       
    57 			iExtra->iFep = newFep;
       
    58 			iExtra->HandleChangeInLoadedFep();
       
    59 			}
       
    60 		}
       
    61 	}
       
    62 
       
    63 static void CleanupResetEComImpArray(TAny* aArray)
       
    64 	{
       
    65 	RImplInfoPtrArray* implementationArray = reinterpret_cast<RImplInfoPtrArray*>(aArray);
       
    66 	implementationArray->ResetAndDestroy();
       
    67 	}
       
    68 	
       
    69 EXPORT_C void CCoeEnv::AvailableFepsL(RArray<TUid>& aUids, CDesCArray* aDisplayNames)
       
    70 /**
       
    71 Gets the UIDs, and optionally display names, of all the secure FEPs that are available.
       
    72 
       
    73 @param	aUids The array of FEP UIDs to be filled.
       
    74 @param	aDisplayNames The array of FEP display names to be filled. May be passed as NULL if display names are not required.
       
    75 */
       
    76 	{
       
    77 	aUids.Reset();
       
    78 	if(aDisplayNames)
       
    79 		{
       
    80 		aDisplayNames->Reset();
       
    81 		}
       
    82 	RImplInfoPtrArray implementationArray;
       
    83 	CleanupStack::PushL(TCleanupItem(CleanupResetEComImpArray, &implementationArray));
       
    84 	REComSession::ListImplementationsL(KUidFepPluginInterface, implementationArray);
       
    85 	const TInt count = implementationArray.Count();
       
    86 	for(TInt index=0; index<count; ++index)
       
    87 		{
       
    88 		CImplementationInformation& impl = *(implementationArray[index]);
       
    89 		User::LeaveIfError(aUids.Append( impl.ImplementationUid() ));
       
    90 		if(aDisplayNames)
       
    91 			{
       
    92 			aDisplayNames->AppendL(impl.DisplayName());
       
    93 			}
       
    94 		}
       
    95 	CleanupStack::PopAndDestroy(&implementationArray);
       
    96 	}
       
    97 
       
    98 EXPORT_C void CCoeEnv::InstallFepL(TUid aFepUid)
       
    99 /**
       
   100 Loads the specified secure FEP into all running applications. 
       
   101 
       
   102 The currently loaded FEP, if any, is unloaded.
       
   103 
       
   104 @param aFepUid The UID of the secure FEP to be loaded.
       
   105 @capability WriteDeviceData		To protect against installation of insecure FEP.
       
   106 */
       
   107 	{
       
   108 	InstallFepL(aFepUid, EFalse);
       
   109 	}
       
   110 
       
   111 EXPORT_C void CCoeEnv::InstallFepL(TUid aFepUid, const TBool aLeave)
       
   112 /**
       
   113 Loads the specified secure FEP into all running applications.
       
   114 
       
   115 The currently loaded FEP, if any, is unloaded.
       
   116 
       
   117 @param aFepUid The UID of the secure FEP to be loaded.
       
   118 @param aLeave No longer used.
       
   119 @capability WriteDeviceData		To protect against installation of insecure FEP.
       
   120 */
       
   121 	{
       
   122 	(void)aLeave;
       
   123 	TBuf<16> fepId;
       
   124 	FepName::NameFromUid(fepId, aFepUid);
       
   125 	CCoeDataStorage::GetL(*this).SetInstalledFepIdL(fepId);
       
   126 	}
       
   127 
       
   128 EXPORT_C void CCoeEnv::ExecuteFepSettingsDialogL(TUid aFepUid)
       
   129 /**
       
   130 Executes the settings dialog for the specified secure FEP.
       
   131 
       
   132 The specified FEP does not need to be loaded.
       
   133 
       
   134 @param aFepUid The UID of the secure FEP for which the settings dialog 
       
   135 is to be executed.
       
   136 */
       
   137 	{
       
   138 	CCoeFepPlugIn* fepPlugIn = CCoeFepPlugIn::NewL(aFepUid);
       
   139 	CleanupStack::PushL(fepPlugIn);
       
   140 	fepPlugIn->SynchronouslyExecuteSettingsDialogL(*this);
       
   141 	CleanupStack::PopAndDestroy(fepPlugIn);
       
   142 	}
       
   143 
       
   144 
       
   145 //
       
   146 
       
   147