sysstatemgmt/systemstarter/src/StartupSplashScreen.cpp
changeset 0 4e1aa6a622a0
child 59 0f7422b6b602
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2005-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 // Start/kill the splash screen. Note that this only works with the techview
       
    15 // splash screen (or any other that responds to the global chunk created
       
    16 // here). This class is provided as a example of a startup command other than
       
    17 // the standard app starter.
       
    18 // 
       
    19 //
       
    20 
       
    21 #include "StartupSplashScreen.h"
       
    22 
       
    23 #include "SysStartDebug.h"
       
    24 #include <e32property.h>
       
    25 #include <sysstartdefs.h>
       
    26 
       
    27 
       
    28 //
       
    29 // Standard Symbian factory functions/destructor
       
    30 //
       
    31 
       
    32 CStartupSplashScreen* CStartupSplashScreen::NewL(TBool aStart, HBufC* aPath)
       
    33 	{
       
    34 	CStartupSplashScreen* self = NewLC(aStart, aPath);
       
    35 	CleanupStack::Pop(self);
       
    36 	return self;
       
    37 	}
       
    38 
       
    39 CStartupSplashScreen* CStartupSplashScreen::NewLC(TBool aStart, HBufC* aPath)
       
    40 	{
       
    41 	CStartupSplashScreen* self = new (ELeave) CStartupSplashScreen(aStart, aPath);
       
    42 	CleanupStack::PushL(self);
       
    43 	return self;
       
    44 	}
       
    45 
       
    46 CStartupSplashScreen::~CStartupSplashScreen()
       
    47 	{
       
    48 	delete iSplashPath;
       
    49 	}
       
    50 
       
    51 //
       
    52 // Public member functions
       
    53 //
       
    54 
       
    55 /** Implementation of MStartupCommand interface.
       
    56 
       
    57 @see MStartupCommand.
       
    58 */
       
    59 void CStartupSplashScreen::Execute(TRequestStatus& aStatus)
       
    60 	{
       
    61 	aStatus = KRequestPending;
       
    62 
       
    63 	TInt err = KErrNone;
       
    64 	if (iStartSplash)
       
    65 		{
       
    66 		err = iSplashPath ? StartSplashScreen() : KErrArgument;
       
    67 		}
       
    68 	else
       
    69 		{
       
    70 		err = KillSplashScreen();
       
    71 		}
       
    72 
       
    73 	TRequestStatus* statusValue = &aStatus;
       
    74 	User::RequestComplete(statusValue, err);
       
    75 	}
       
    76 
       
    77 //
       
    78 // Private functions
       
    79 //
       
    80 
       
    81 CStartupSplashScreen::CStartupSplashScreen(TBool aStart, HBufC* aPath) :
       
    82 	iStartSplash(aStart),
       
    83 	iSplashPath(aPath)
       
    84 	{
       
    85 	}
       
    86 
       
    87 TInt CStartupSplashScreen::StartSplashScreen()
       
    88 	{
       
    89 	DEBUGPRINT2(_L("SysStart: Start splash screen %S"), iSplashPath); 
       
    90 	            
       
    91 	_LIT_SECURITY_POLICY_PASS(KSplashReadPolicy);
       
    92 	_LIT_SECURITY_POLICY_S0(KSplashWritePolicy, RProcess().SecureId());   
       
    93    
       
    94   	// Define a splash property to control display and removal of
       
    95   	// the splash screen on system start up.    
       
    96  	RProperty::Define(KSplashPropertyKey, RProperty::EInt, 
       
    97  							KSplashReadPolicy, KSplashWritePolicy);
       
    98   
       
    99  	// Create and set off the splash screen process.
       
   100 	RProcess splash;	 
       
   101 	TInt err = splash.Create(*iSplashPath, KNullDesC);
       
   102 	if (err == KErrNone)
       
   103 		{
       
   104 		splash.Resume();
       
   105 		splash.Close();
       
   106 		}
       
   107 	
       
   108 	return err;
       
   109 	}
       
   110 
       
   111 TInt CStartupSplashScreen::KillSplashScreen()
       
   112 	{
       
   113 	DEBUGPRINT1(_L("SysStart: Kill splash screen"));
       
   114   
       
   115   	// Set the splash property so that it indicates that the splash screen
       
   116   	// can now be removed. 
       
   117  	const TInt KOkayToRemoveSplash = 1;  
       
   118  	TInt err = RProperty::Set(KSysStartPropertyCat, KSplashPropertyKey, KOkayToRemoveSplash);
       
   119 	return err;  
       
   120 	}
       
   121 
       
   122 void CStartupSplashScreen::Release() 
       
   123 	{
       
   124 	delete this;
       
   125 	}