sysstatemgmt/systemstatereferenceplugins/test/tintcustcmd/src/definesecuritystateps.cpp
changeset 0 4e1aa6a622a0
child 52 d6b9e89d80a3
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2008-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 // defineemergencycallps.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @test
       
    21  @internalComponent - Internal Symbian test code
       
    22 */
       
    23 
       
    24 #include <eikstart.h> 
       
    25 #include <eikapp.h>
       
    26 #include <e32property.h>
       
    27 #include "definesecuritystateps.h"
       
    28 
       
    29 /**
       
    30 Standard DLL entry point function.
       
    31 Creates and returns an instance of the CApaApplication-derived class.
       
    32 @return an instance of the CApaApplication-derived class
       
    33 */
       
    34 TInt E32Main()
       
    35 	{
       
    36 	return EikStart::RunApplication( CTestApplication::NewApplication );
       
    37 	}
       
    38 
       
    39 CTestApplication::CTestApplication()
       
    40 	{
       
    41 	}
       
    42 
       
    43 CTestApplication::~CTestApplication()
       
    44 	{
       
    45 	}
       
    46 		
       
    47 /**
       
    48 @return The application's UID 
       
    49 */
       
    50 TUid CTestApplication::AppDllUid() const
       
    51 	{
       
    52 	const TUid dll = {0x2000E664};
       
    53 	return dll;
       
    54 	}
       
    55 
       
    56 /**
       
    57 @return CTestApplication or NULL if KErrNoMemory
       
    58 */
       
    59 CApaApplication* CTestApplication::NewApplication()
       
    60 	{
       
    61 	// As the framework has at this point not started up enough, and therefore the TRAP-harness and 
       
    62 	// exception handlers aren’t available yet, this factory function is a non-leaving function and 
       
    63 	// can't use the new(Eleave) operator.
       
    64 	return new CTestApplication();
       
    65 	}
       
    66 	
       
    67 /**
       
    68 Called by the UI framework at application start-up to create an instance of the document class.
       
    69 @leave	KErrNoMemory
       
    70 @return A CTestDocument
       
    71 */
       
    72 CApaDocument* CTestApplication::CreateDocumentL()
       
    73 	{
       
    74 	return CTestDocument::NewL(*this);
       
    75 	}
       
    76 
       
    77 CTestDocument::CTestDocument(CEikApplication& aApp) : CEikDocument(aApp)
       
    78 	{
       
    79 	}
       
    80 
       
    81 CTestDocument::~CTestDocument()
       
    82 	{
       
    83 	}
       
    84 
       
    85 /**
       
    86 Factory function for this class
       
    87 @return a new CEndTaskTestDocument instance.
       
    88 */
       
    89 CTestDocument* CTestDocument::NewL(CEikApplication& aApp)
       
    90 	{
       
    91 	return new(ELeave) CTestDocument(aApp);
       
    92 	}
       
    93 
       
    94 
       
    95 /**
       
    96 Called by the UI framework to construct the application UI class. 
       
    97 Note that the app UI's ConstructL() is called by the UI framework.
       
    98 */
       
    99 CEikAppUi* CTestDocument::CreateAppUiL()
       
   100 	{
       
   101 	return new(ELeave) CTestAppUi();
       
   102 	}
       
   103 
       
   104 CTestAppUi::CTestAppUi()
       
   105 	{
       
   106 	}
       
   107 
       
   108 CTestAppUi::~CTestAppUi()
       
   109 	{
       
   110 	}
       
   111 
       
   112 void CTestAppUi::ConstructL()
       
   113 	{
       
   114 	//This appplication is used to define the property used by CSsmUiSpecific::SecurityStatus() and CSsmUiSpecific::SetSecurityStatus. Uid3 of the 
       
   115 	//application should be same as the security status property category uid. This is to allow the application to define the property as
       
   116 	//security state property uid falls under system range.
       
   117 
       
   118 	const TUid KSecurityStatusPropertyCategory =  {0x2000E664};
       
   119 	const TUint KSecurityStatusPropertyKey = 0x0101; 
       
   120 	const TUint32 KStarterSecurityPhase = 0x00000001;
       
   121 	//Define the property for emergency call
       
   122 	_LIT_SECURITY_POLICY_PASS(KAllowAllPolicy);
       
   123 	TInt result = RProperty::Define(KSecurityStatusPropertyCategory, KSecurityStatusPropertyKey, RProperty::EInt,
       
   124 									KAllowAllPolicy, KAllowAllPolicy);
       
   125 
       
   126 	_LIT(KPRINT,"Return code for RProperty::Define for security state property key - %d -");
       
   127 	RDebug::Print(KPRINT, result);
       
   128 	
       
   129 	if( KErrNone != result && KErrAlreadyExists != result)
       
   130 		{
       
   131 		User::Leave(result);
       
   132 		}
       
   133 	
       
   134 	//Define the property for security call
       
   135 	result = RProperty::Define(KSecurityStatusPropertyCategory, KStarterSecurityPhase, RProperty::EInt,
       
   136 									KAllowAllPolicy, KAllowAllPolicy);
       
   137 
       
   138 	RDebug::Print(KPRINT, result);
       
   139 	
       
   140 	if( KErrNone != result && KErrAlreadyExists != result)
       
   141 		{
       
   142 		User::Leave(result);
       
   143 		}
       
   144 
       
   145 	// Complete the UI framework's construction of the App UI.
       
   146 	BaseConstructL(CEikAppUi::ENoAppResourceFile);
       
   147 	}