sysstatemgmt/systemstatemgr/cmd/src/cmdstartprocess.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2007-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 "ssmcommandparameters.h"
       
    17 #include "cmdstartprocess.h"
       
    18 #include "ssmdebug.h"
       
    19 #include "ssmpanic.h"
       
    20 
       
    21 /**
       
    22 Used to create an instance of CCmdStartProcess class from a read stream.
       
    23 CSsmCommandList::InternalizeL() uses this method to construct a command from stream.
       
    24 
       
    25 @param aReadStream 	Read stream containing data through which object can be created
       
    26 @return				A pointer to an object of type CCmdStartProcess.
       
    27 */
       
    28 CCmdStartProcess* CCmdStartProcess::NewL(RReadStream& aReadStream)
       
    29 	{
       
    30 	CCmdStartProcess* self = new (ELeave) CCmdStartProcess();
       
    31 	CleanupStack::PushL(self);
       
    32 	self->ConstructL(aReadStream);
       
    33 	CleanupStack::Pop(self);
       
    34 	return self;
       
    35 	}
       
    36 
       
    37 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE
       
    38 /**
       
    39 Used to create an instance of CCmdStartProcess class from given parameters.
       
    40 This method is used by SsmCommandFactory to create a command.
       
    41 
       
    42 @param aSeverity The severity of the command
       
    43 @param aAppInfo Contains information which can be used to start the process
       
    44 @param aPriority The priority of the command in the list
       
    45 @panic ECmdNullPtr if the information used to create command is null
       
    46 @return	A pointer to an object of type CCmdStartProcess.
       
    47 */
       
    48 CCmdStartProcess* CCmdStartProcess::NewL(TCmdErrorSeverity aSeverity, const CSsmStartupProperties *aAppInfo, const TUint16 aPriority)
       
    49 	{
       
    50 	__ASSERT_ALWAYS(aAppInfo != NULL, PanicNow(KPanicCmdStartProcess, ECmdNullPtr));
       
    51 	CCmdStartProcess* self = new (ELeave) CCmdStartProcess(aSeverity, aPriority);
       
    52 	CleanupStack::PushL(self);
       
    53 	self->ConstructL(aAppInfo);
       
    54 	CleanupStack::Pop(self);
       
    55 	return self;
       
    56 	}
       
    57 #endif
       
    58 
       
    59 /**
       
    60 Used to create an instance of CCmdStartProcess class from given parameters.
       
    61 This method is used by SsmCommandFactory to create a command.
       
    62 
       
    63 @param aSeverity The severity of the command
       
    64 @param aAppInfo Contains information which can be used to start the process
       
    65 @panic ECmdNullPtr if the information used to create command is null
       
    66 @return	A pointer to an object of type CCmdStartProcess.
       
    67 */
       
    68 CCmdStartProcess* CCmdStartProcess::NewL(TCmdErrorSeverity aSeverity, const CSsmStartupProperties *aAppInfo)
       
    69 	{
       
    70 	__ASSERT_ALWAYS(aAppInfo != NULL, PanicNow(KPanicCmdStartProcess, ECmdNullPtr));
       
    71 	CCmdStartProcess* self = new (ELeave) CCmdStartProcess(aSeverity);
       
    72 	CleanupStack::PushL(self);
       
    73 	self->ConstructL(aAppInfo);
       
    74 	CleanupStack::Pop(self);
       
    75 	return self;
       
    76 	}
       
    77 
       
    78 /**
       
    79 Used to create an instance of CCmdStartProcess class from CCmdStartProcess object
       
    80 Must be used only by CLE
       
    81 @param aCmdStartProcess CCmdStartProcess reference 
       
    82 @param aUtilProvider CSsmCommandUtilProvider reference 
       
    83 @return A pointer to an object of type CCmdStartProcess.
       
    84 */
       
    85 CCmdStartProcess* CCmdStartProcess::NewLC(const CCmdStartProcess& aCmdStartProcess, CSsmCommandUtilProvider* aUtilProvider)
       
    86     {
       
    87 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE
       
    88     CCmdStartProcess* self = new (ELeave) CCmdStartProcess(aCmdStartProcess.Severity(),aCmdStartProcess.Priority());
       
    89 #else
       
    90     CCmdStartProcess* self = new (ELeave) CCmdStartProcess(aCmdStartProcess.Severity());
       
    91 #endif
       
    92     CleanupStack::PushL(self);
       
    93     self->ConstructL(aCmdStartProcess, aUtilProvider);
       
    94     return self;
       
    95     }
       
    96 
       
    97 void CCmdStartProcess::ConstructL(const CCmdStartProcess& aCmdStartProcess, CSsmCommandUtilProvider* aUtilProvider)
       
    98     {
       
    99     iConditionalResourceId = aCmdStartProcess.ConditionalInformation();
       
   100 	SetUtilProvider(*aUtilProvider);
       
   101 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE
       
   102 	if (iConditionalResourceId != 0)
       
   103         {
       
   104         SetCommandResourceFileNameL(aCmdStartProcess.GetCommandResourceFileName());
       
   105         }
       
   106 #endif
       
   107     CCmdStarterBase::ConstructL(aCmdStartProcess.AppInfo(),FALSE);
       
   108     }
       
   109 
       
   110 /**
       
   111 Used to create an instance of CCmdStartProcess class from resource.
       
   112 
       
   113 @param aCommandParameters Object data from a resource file
       
   114 @return	A pointer to an object of type CCmdStartProcess.
       
   115 */
       
   116 CCmdStartProcess* CCmdStartProcess::NewL(TSsmCommandParameters& aCommandParameters)
       
   117 	{
       
   118 	CCmdStartProcess* self = new (ELeave) CCmdStartProcess();
       
   119 	CleanupStack::PushL(self);
       
   120 	self->ConstructL(aCommandParameters);
       
   121 	CleanupStack::Pop(self);
       
   122 	return self;
       
   123 	}
       
   124 
       
   125 /**
       
   126 Returns the version of the BIC
       
   127 @return		The maximum supported version of the BIC
       
   128 */
       
   129 TInt CCmdStartProcess::MaxSupportedVersion()
       
   130 	{
       
   131 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE
       
   132 	return (static_cast<TInt>(ECmdStartProcessVersionWithPriority));
       
   133 #else
       
   134 	return (static_cast<TInt>(ECmdStartProcessInitialVersion));
       
   135 #endif	
       
   136 	}
       
   137 
       
   138 /**
       
   139 Destructor
       
   140 */
       
   141 CCmdStartProcess::~CCmdStartProcess()
       
   142 	{
       
   143 	}
       
   144 
       
   145 /**
       
   146 Overloaded constructor
       
   147 */
       
   148 CCmdStartProcess::CCmdStartProcess()
       
   149 	: CCmdStarterBase(ESsmCmdStartProcess)
       
   150 	{
       
   151 	}
       
   152 
       
   153 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE
       
   154 /**
       
   155 Overloaded constructor
       
   156 @param aSeverity Severity of command
       
   157 @param aPriority The priority of the command in the list
       
   158 */
       
   159 CCmdStartProcess::CCmdStartProcess(TCmdErrorSeverity aSeverity, const TUint16 aPriority)
       
   160 	: CCmdStarterBase(ESsmCmdStartProcess, aSeverity, aPriority)
       
   161 	{
       
   162 	}
       
   163 #endif
       
   164 
       
   165 /**
       
   166 Overloaded constructor
       
   167 @param aSeverity Severity of command
       
   168 */
       
   169 CCmdStartProcess::CCmdStartProcess(TCmdErrorSeverity aSeverity)
       
   170 	: CCmdStarterBase(ESsmCmdStartProcess, aSeverity)
       
   171 	{
       
   172 	}
       
   173 
       
   174 /**
       
   175 Constructs an object from resource file.
       
   176 @param aCommandParameters Object data from a resource file
       
   177 */
       
   178 void CCmdStartProcess::ConstructL(TSsmCommandParameters& aCommandParameters)
       
   179 	{
       
   180 	RResourceReader& reader = aCommandParameters.MainReader();
       
   181 	const TSsmCommandType type = static_cast<TSsmCommandType>(reader.ReadInt16L());
       
   182 	SSMLOGLEAVEIFFALSE(type == Type(), KErrNotSupported);
       
   183 	const TInt version = reader.ReadInt16L();
       
   184 	SSMLOGLEAVEIFFALSE(__COMPARE_VERSION(version, CCmdStartProcess::MaxSupportedVersion()), KErrNotSupported);
       
   185 	CCmdStarterBase::ConstructL(aCommandParameters);
       
   186 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE
       
   187 	iPriority = (version > ECmdStartProcessInitialVersion)? reader.ReadUint16L() : KDefaultCommandPriority ;
       
   188 #endif
       
   189 	}
       
   190 
       
   191 /**
       
   192 Configures the BIC using data contained in a ReadStream
       
   193 @param aReadStream 	A read stream containing BIC data
       
   194 */
       
   195 void CCmdStartProcess::ConstructL(RReadStream& aReadStream)
       
   196 	{
       
   197 	CCmdStarterBase::ConstructL(aReadStream);
       
   198 	}
       
   199 
       
   200 /**
       
   201 Constructs an object from aAppInfo.
       
   202 @param aAppInfo Startup properties through which command will be constructed.
       
   203 */
       
   204 void CCmdStartProcess::ConstructL(const CSsmStartupProperties *aAppInfo)
       
   205 	{
       
   206 	CCmdStarterBase::ConstructL(aAppInfo);
       
   207 	}