sysstatemgmt/systemstatemgr/cmd/src/cmdwaitforapparcinit.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 <s32strm.h>
       
    17 #include <barsread2.h>
       
    18 
       
    19 #include "ssmcommandparameters.h"
       
    20 #include "ssmcommandutilprovider.h"
       
    21 #include "cmdwaitforapparcinit.h"
       
    22 #include "ssmdebug.h"
       
    23 #include "ssmpanic.h"
       
    24 
       
    25 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE
       
    26 /**
       
    27 Used to create an instance of CCmdWaitForApparcInit class from given parameters.
       
    28 This method is used by SsmCommandFactory to create a command.
       
    29 
       
    30 @param aSeverity The severity of the command
       
    31 @param aPriority The priority of the command in the list
       
    32 @return	A pointer to an object of type CCmdWaitForApparcInit.
       
    33 */
       
    34 CCmdWaitForApparcInit* CCmdWaitForApparcInit::NewL(TCmdErrorSeverity aSeverity, const TUint16 aPriority)
       
    35 	{
       
    36 	CCmdWaitForApparcInit* self = new (ELeave) CCmdWaitForApparcInit(aSeverity, aPriority);
       
    37 	return self;
       
    38 	}
       
    39 #endif
       
    40 
       
    41 /**
       
    42 Used to create an instance of CCmdWaitForApparcInit class from given parameters.
       
    43 This method is used by SsmCommandFactory to create a command.
       
    44 
       
    45 @param aSeverity The severity of the command
       
    46 @return	A pointer to an object of type CCmdWaitForApparcInit.
       
    47 */
       
    48 CCmdWaitForApparcInit* CCmdWaitForApparcInit::NewL(TCmdErrorSeverity aSeverity)
       
    49 	{
       
    50 	CCmdWaitForApparcInit* self = new (ELeave) CCmdWaitForApparcInit(aSeverity);
       
    51 	return self;
       
    52 	}
       
    53 
       
    54 /**
       
    55 Used to create an instance of CCmdWaitForApparcInit class from a read stream.
       
    56 CSsmCommandList::InternalizeL() this method to construct a command from stream.
       
    57 
       
    58 @param aReadStream Read stream containing data through which object can be created
       
    59 @return	A pointer to an object of type CCmdWaitForApparcInit.
       
    60 */
       
    61 CCmdWaitForApparcInit* CCmdWaitForApparcInit::NewL(RReadStream& aReadStream)
       
    62 	{
       
    63 	CCmdWaitForApparcInit* self = new (ELeave) CCmdWaitForApparcInit();
       
    64 	CleanupStack::PushL(self);
       
    65 	self->ConstructL(aReadStream);
       
    66 	CleanupStack::Pop(self);
       
    67 	return self;
       
    68 	}
       
    69 
       
    70 /**
       
    71 Used to create an instance of CCmdWaitForApparcInit class from resource.
       
    72 
       
    73 @param aCommandParameters Object data from a resource file
       
    74 @return	A pointer to an object of type CCmdWaitForApparcInit.
       
    75 */
       
    76 CCmdWaitForApparcInit* CCmdWaitForApparcInit::NewL(TSsmCommandParameters& aCommandParameters)
       
    77 	{
       
    78 	CCmdWaitForApparcInit* self = new (ELeave) CCmdWaitForApparcInit();
       
    79 	CleanupStack::PushL(self);
       
    80 	self->ConstructL(aCommandParameters);
       
    81 	CleanupStack::Pop(self);
       
    82 	return self;
       
    83 	}
       
    84 /**
       
    85 Used to create an instance of CCmdWaitForApparcInit class from CCmdWaitForApparcInit object
       
    86 Must be used only by CLE
       
    87 @param aCmdWaitForApparcInit CCmdWaitForApparcInit reference 
       
    88 @param aUtilProvider CSsmCommandUtilProvider reference 
       
    89 @return A pointer to an object of type CCmdWaitForApparcInit.
       
    90 */
       
    91 CCmdWaitForApparcInit* CCmdWaitForApparcInit::NewLC(const CCmdWaitForApparcInit& aCmdWaitForApparcInit, CSsmCommandUtilProvider* aUtilProvider)
       
    92     {
       
    93 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE
       
    94     CCmdWaitForApparcInit* self = new (ELeave) CCmdWaitForApparcInit(aCmdWaitForApparcInit.Severity(),aCmdWaitForApparcInit.Priority());
       
    95 #else
       
    96     CCmdWaitForApparcInit* self = new (ELeave) CCmdWaitForApparcInit(aCmdWaitForApparcInit.Severity());
       
    97 #endif
       
    98     CleanupStack::PushL(self);
       
    99     self->ConstructL(aCmdWaitForApparcInit, aUtilProvider);
       
   100     return self;
       
   101     }
       
   102 
       
   103 void CCmdWaitForApparcInit::ConstructL(const CCmdWaitForApparcInit& aCmdWaitForApparcInit, CSsmCommandUtilProvider* aUtilProvider)
       
   104     {
       
   105     iConditionalResourceId = aCmdWaitForApparcInit.ConditionalInformation();
       
   106     SetUtilProvider(*aUtilProvider);
       
   107 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE
       
   108     if (iConditionalResourceId != 0)
       
   109         {
       
   110         SetCommandResourceFileNameL(aCmdWaitForApparcInit.GetCommandResourceFileName());
       
   111         }
       
   112 #endif    
       
   113     }
       
   114 
       
   115 /**
       
   116 Returns the version of the BIC
       
   117 @return		The maximum supported version of the BIC
       
   118 */
       
   119 TInt CCmdWaitForApparcInit::MaxSupportedVersion()
       
   120 	{
       
   121 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE
       
   122 	return (static_cast<TInt>(ECmdWaitForApparcInitVersionWithPriority));
       
   123 #else
       
   124 	return (static_cast<TInt>(ECmdWaitForApparcInitInitialVersion));
       
   125 #endif
       
   126 	}
       
   127 /**
       
   128 Destructor
       
   129 */
       
   130 CCmdWaitForApparcInit::~CCmdWaitForApparcInit()
       
   131 	{
       
   132 	Cancel();
       
   133 	}
       
   134 
       
   135 /**
       
   136 Execute this command
       
   137 @param aStatus 	Completed to indicate execution of the next command may begin.		
       
   138 @panic ECmdNullPtr if the information used to create command is null
       
   139 */
       
   140 void CCmdWaitForApparcInit::Execute(TRequestStatus& aStatus)
       
   141 	{
       
   142 	__ASSERT_ALWAYS(iUtilProvider, PanicNow(KPanicCmdWaitForApparcInit, ECmdNullPtr));
       
   143 	aStatus = KRequestPending;
       
   144 	iExecuteRequest = &aStatus;
       
   145 	
       
   146 	iUtilProvider->StartSafe().InitApparcServer(iStatus);
       
   147 	SetActive();
       
   148 	}
       
   149 
       
   150 /**
       
   151 Releases resources associated with this BIC
       
   152 */
       
   153 void CCmdWaitForApparcInit::Release()
       
   154 	{
       
   155 	delete this;
       
   156 	}
       
   157 
       
   158 /**
       
   159 Cancels the BIC
       
   160 */
       
   161 void CCmdWaitForApparcInit::ExecuteCancel()
       
   162 	{
       
   163 	//cancel the outstanding request
       
   164 	Cancel();
       
   165 	//and complete the request with KErrCancel
       
   166 	CompleteExecuteRequest(KErrCancel);
       
   167 	}
       
   168 
       
   169 /**
       
   170 Returns the type of the BIC
       
   171 @return Type of BIC
       
   172 */
       
   173 TSsmCommandType CCmdWaitForApparcInit::Type() const
       
   174 	{
       
   175 	DEBUGPRINT2A("Command type: %d", ESsmCmdWaitForApparcInit);
       
   176 	return (ESsmCmdWaitForApparcInit);
       
   177 	}
       
   178 
       
   179 /**
       
   180 Externalises the configuration of the BIC
       
   181 
       
   182 @param aWriteStream A write stream to write BIC data to
       
   183 */
       
   184 void CCmdWaitForApparcInit::ExternalizeL(RWriteStream& aWriteStream) const
       
   185 	{
       
   186 	aWriteStream.WriteInt16L(iSeverity);
       
   187 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE
       
   188 	aWriteStream.WriteUint16L(iPriority);
       
   189 #endif
       
   190 	}
       
   191 
       
   192 /**
       
   193 Handles command's request completion event.
       
   194 */
       
   195 void CCmdWaitForApparcInit::RunL()
       
   196 	{
       
   197 	CompleteExecuteRequest(iStatus.Int());
       
   198 	}
       
   199 
       
   200 /**
       
   201 cancellation of an outstanding request.
       
   202 */
       
   203 void CCmdWaitForApparcInit::DoCancel()
       
   204 	{
       
   205 	iUtilProvider->StartSafe().InitApparcServerCancel();
       
   206 	}
       
   207 
       
   208 /**
       
   209 Complete the command request with aError. It gets called when RunL leaves.
       
   210 
       
   211 @param aError Error code with which RunL has left.
       
   212 @return KErrNone as error is handled in this function.
       
   213 */
       
   214 TInt CCmdWaitForApparcInit::RunError(TInt aError)
       
   215 	{
       
   216 	DEBUGPRINT2A("CCmdWaitForApparcInit::RunError called with reason %d", aError);
       
   217 	CompleteExecuteRequest(aError);
       
   218 	return KErrNone;
       
   219 	}
       
   220 
       
   221 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE
       
   222 /**
       
   223 Overloaded constructor.
       
   224 @param aSeverity Severity for this BIC
       
   225 @param aPriority The priority of the command in the list
       
   226  */
       
   227 CCmdWaitForApparcInit::CCmdWaitForApparcInit(TCmdErrorSeverity aSeverity, const TUint16 aPriority)
       
   228 	: CSsmCommandBase(aSeverity, aPriority)
       
   229 	{
       
   230 	}
       
   231 #endif
       
   232 
       
   233 /**
       
   234 Overloaded constructor.
       
   235 @param aSeverity Severity for this BIC
       
   236  */
       
   237 CCmdWaitForApparcInit::CCmdWaitForApparcInit(TCmdErrorSeverity aSeverity)
       
   238 	: CSsmCommandBase(aSeverity)
       
   239 	{
       
   240 	}
       
   241 
       
   242 /**
       
   243 Default constructor.
       
   244 */
       
   245 CCmdWaitForApparcInit::CCmdWaitForApparcInit()
       
   246 	{
       
   247 	}
       
   248 
       
   249 /**
       
   250 Constructs an object from resource file.
       
   251 
       
   252 @param aCommandParameters Object data from a resource file
       
   253 */
       
   254 void CCmdWaitForApparcInit::ConstructL(TSsmCommandParameters& aCommandParameters)
       
   255 	{
       
   256 	RResourceReader& reader = aCommandParameters.MainReader();
       
   257 	const TSsmCommandType type = static_cast<TSsmCommandType>(reader.ReadInt16L());
       
   258 	SSMLOGLEAVEIFFALSE(type == Type(), KErrNotSupported);
       
   259 	const TInt version = reader.ReadInt16L();
       
   260 	SSMLOGLEAVEIFFALSE(__COMPARE_VERSION(version, CCmdWaitForApparcInit::MaxSupportedVersion()), KErrNotSupported);
       
   261 	iSeverity = static_cast<TCmdErrorSeverity>(reader.ReadInt16L());
       
   262 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE
       
   263 	iPriority = (version > ECmdWaitForApparcInitInitialVersion) ? reader.ReadUint16L() : KDefaultCommandPriority;
       
   264 #endif
       
   265 	}
       
   266 
       
   267 /**
       
   268 Constructs an object from a read stream.
       
   269 
       
   270 @param aReadStream Read stream containing data through which object can be created
       
   271 */
       
   272 void CCmdWaitForApparcInit::ConstructL(RReadStream& aReadStream)
       
   273 	{
       
   274 	InternalizeL(aReadStream);
       
   275 	}
       
   276 
       
   277 /**
       
   278 Configures the BIC using data contained in a ReadStream
       
   279  
       
   280 @param aReadStream 	A read stream containing BIC data
       
   281 */
       
   282 void CCmdWaitForApparcInit::InternalizeL(RReadStream& aReadStream)
       
   283 	{
       
   284 	iSeverity = static_cast<TCmdErrorSeverity>(aReadStream.ReadInt16L());
       
   285 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE
       
   286 	iPriority = aReadStream.ReadUint16L();
       
   287 #endif
       
   288 	}