sysstatemgmt/systemstatereferenceplugins/test/tunitcustcmd/src/definestartupps.cpp
changeset 0 4e1aa6a622a0
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 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @test
       
    19  @internalComponent - Internal Symbian test code
       
    20 */
       
    21 
       
    22 #include <eikstart.h> 
       
    23 #include <eikapp.h>
       
    24 #include <e32property.h>
       
    25 #include <ssm/startupdomainpskeys.h>
       
    26 #include "definestartupps.h"
       
    27 #include "ssmuiproviderdll.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 = {0x2000E65E};
       
    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 for startup. Uid3 of the application should be 
       
   115 	//same as the startup property uid. This is to allow the application to define the property as
       
   116 	//startup property uid falls under system range.
       
   117 
       
   118 	_LIT_SECURITY_POLICY_PASS(KAllowAllPolicy);
       
   119 
       
   120 	TBuf<20> commandLine;
       
   121 	User::CommandLine(commandLine);
       
   122 	
       
   123 	TInt result = KErrNone;
       
   124 
       
   125 	_LIT(KStartUpPSKeys, "startupkeys");
       
   126 	if (!(commandLine.Compare(KStartUpPSKeys)))
       
   127 	    {
       
   128         //Define the property for global statup mode.
       
   129         result = RProperty::Define(CSsmUiSpecific::StartupPSUid(), KPSGlobalStartupMode, RProperty::EInt,
       
   130                                         KAllowAllPolicy, KAllowAllPolicy);
       
   131 
       
   132 	    _LIT(KPRINT6,"Success code for RProperty::Define for global statup mode property key - %d -");
       
   133 	    RDebug::Print(KPRINT6, result);
       
   134 	    if ((KErrNone != result) && (KErrAlreadyExists !=result))
       
   135 	        {
       
   136 	        User::Leave(result);	        
       
   137 	        }
       
   138    
       
   139 	    //Define the property for global statup mode.
       
   140 	    result = RProperty::Define(CSsmUiSpecific::StartupPSUid(), KPSStartupReason, RProperty::EInt,
       
   141 	                                    KAllowAllPolicy, KAllowAllPolicy);
       
   142 
       
   143 	    _LIT(KPRINT7,"Success code for RProperty::Define for statup reason property key - %d -");
       
   144 	    RDebug::Print(KPRINT7, result);
       
   145         if ((KErrNone != result) && (KErrAlreadyExists !=result))
       
   146             {
       
   147             User::Leave(result);            
       
   148             }
       
   149 	    }
       
   150 	else
       
   151 	    {
       
   152 	    //Define the property for sim status.
       
   153 	    result = RProperty::Define(CSsmUiSpecific::StartupPSUid(), CSsmUiSpecific::SimStatusPropertyKey(), RProperty::EInt,
       
   154 	                                    KAllowAllPolicy, KAllowAllPolicy);
       
   155 	    
       
   156 	    _LIT(KPRINT1,"Success code for RProperty::Define for sim status property key - %d -");
       
   157 	    RDebug::Print(KPRINT1, result);
       
   158         if ((KErrNone != result) && (KErrAlreadyExists !=result))
       
   159             {
       
   160             User::Leave(result);            
       
   161             }
       
   162         
       
   163 	    //Define the property for sim security status.
       
   164 	    result = RProperty::Define(CSsmUiSpecific::StartupPSUid(), KStartupSimSecurityStatus, RProperty::EInt,
       
   165 	                                    KAllowAllPolicy, KAllowAllPolicy);
       
   166 
       
   167 	    _LIT(KPRINT2,"Success code for RProperty::Define for sim security status property key - %d -");
       
   168 	    RDebug::Print(KPRINT2, result);
       
   169         if ((KErrNone != result) && (KErrAlreadyExists !=result))
       
   170             {
       
   171             User::Leave(result);            
       
   172             }
       
   173 
       
   174 	    //Define the property for splash status.
       
   175 	    result = RProperty::Define(CSsmUiSpecific::StartupPSUid(), KPSSplashShutdown, RProperty::EInt,
       
   176 	                                    KAllowAllPolicy, KAllowAllPolicy);
       
   177 
       
   178 	    _LIT(KPRINT3,"Success code for RProperty::Define for splash status property key - %d -");
       
   179 	    RDebug::Print(KPRINT3, result);
       
   180         if ((KErrNone != result) && (KErrAlreadyExists !=result))
       
   181             {
       
   182             User::Leave(result);            
       
   183             }
       
   184 	    //Define the property for security code status.
       
   185 	    result = RProperty::Define(CSsmUiSpecific::StartupPSUid(), KStartupSecurityCodeQueryStatus, RProperty::EInt,
       
   186 	                                    KAllowAllPolicy, KAllowAllPolicy);
       
   187 
       
   188 	    _LIT(KPRINT4,"Success code for RProperty::Define for security code query status property key - %d -");
       
   189 	    RDebug::Print(KPRINT4, result);
       
   190         if ((KErrNone != result) && (KErrAlreadyExists !=result))
       
   191             {
       
   192             User::Leave(result);            
       
   193             }
       
   194 
       
   195 	    //Define the property for security code status.
       
   196 	    result = RProperty::Define(CSsmUiSpecific::StartupPSUid(), KStartupSecurityCodeStatus, RProperty::EInt,
       
   197 	                                    KAllowAllPolicy, KAllowAllPolicy);
       
   198 
       
   199 	    _LIT(KPRINT5,"Success code for RProperty::Define for security code query status property key - %d -");
       
   200 	    RDebug::Print(KPRINT5, result);
       
   201         if ((KErrNone != result) && (KErrAlreadyExists !=result))
       
   202             {
       
   203             User::Leave(result);            
       
   204             }
       
   205 	    }
       
   206 	RProcess::Rendezvous(KErrNone);
       
   207 	// Complete the UI framework's construction of the App UI.
       
   208 	BaseConstructL(CEikAppUi::ENoAppResourceFile);
       
   209 	}