sysstatemgmt/systemstatemgr/cmd/src/cmdfinalisedrives.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 #include <f32file.h>
       
    19 
       
    20 #include "cmdfinalisedrives.h"
       
    21 #include "ssmcommandparameters.h"
       
    22 #include "ssmdebug.h"
       
    23 #include "ssmpanic.h"
       
    24 
       
    25 /**
       
    26 Used to create an instance of CCmdFinaliseDrives class from a read stream.
       
    27 CSsmCommandList::InternalizeL() uses this method to construct a command from stream.
       
    28 
       
    29 @param aReadStream Read stream containing data through which object can be created
       
    30 @return	A pointer to an object of type CCmdFinaliseDrives.
       
    31 */
       
    32 CCmdFinaliseDrives* CCmdFinaliseDrives::NewL(RReadStream& aReadStream)
       
    33 	{
       
    34 	CCmdFinaliseDrives* self = new (ELeave) CCmdFinaliseDrives();
       
    35 	CleanupStack::PushL(self);
       
    36 	self->ConstructL(aReadStream);
       
    37 	CleanupStack::Pop(self);
       
    38 	return self;
       
    39 	}
       
    40 
       
    41 /**
       
    42 Used to create an instance of CCmdFinaliseDrives 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 CCmdFinaliseDrives.
       
    47 */
       
    48 CCmdFinaliseDrives* CCmdFinaliseDrives::NewL(TCmdErrorSeverity aSeverity)
       
    49 	{
       
    50 	CCmdFinaliseDrives* self = new (ELeave) CCmdFinaliseDrives(aSeverity);
       
    51 	return self;
       
    52 	}
       
    53 
       
    54 /**
       
    55 Used to create an instance of CCmdFinaliseDrives class from resource.
       
    56 
       
    57 @param aCommandParameters Object data from a resource file
       
    58 @return	A pointer to an object of type CCmdFinaliseDrives.
       
    59 */
       
    60 CCmdFinaliseDrives* CCmdFinaliseDrives::NewL(TSsmCommandParameters& aCommandParameters)
       
    61 	{
       
    62 	CCmdFinaliseDrives* self = new (ELeave) CCmdFinaliseDrives();
       
    63 	CleanupStack::PushL(self);
       
    64 	self->ConstructL(aCommandParameters);
       
    65 	CleanupStack::Pop(self);
       
    66 	return self;
       
    67 	}
       
    68 
       
    69 /**
       
    70 Used to create an instance of CCmdFinaliseDrives class from CCmdFinaliseDrives object
       
    71 Must be used only by CLE
       
    72 @param aCmdFinaliseDrives CCmdFinaliseDrives reference 
       
    73 @return A pointer to an object of type CCmdFinaliseDrives.
       
    74 */
       
    75 CCmdFinaliseDrives* CCmdFinaliseDrives::NewLC(const CCmdFinaliseDrives& aCmdFinaliseDrives)
       
    76     {
       
    77     CCmdFinaliseDrives* self = new (ELeave) CCmdFinaliseDrives(aCmdFinaliseDrives.Severity());
       
    78     CleanupStack::PushL(self);
       
    79     self->ConstructL(aCmdFinaliseDrives);
       
    80     return self;
       
    81     }
       
    82 
       
    83 void CCmdFinaliseDrives::ConstructL(const CCmdFinaliseDrives& aCmdFinaliseDrives)
       
    84     {
       
    85     iConditionalResourceId = aCmdFinaliseDrives.ConditionalInformation();
       
    86 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE
       
    87 	if (iConditionalResourceId != 0)
       
    88         {
       
    89         SetCommandResourceFileNameL(aCmdFinaliseDrives.GetCommandResourceFileName());
       
    90         }
       
    91 #endif
       
    92     }
       
    93 
       
    94 /**
       
    95 Destructor
       
    96 */	
       
    97 CCmdFinaliseDrives::~CCmdFinaliseDrives()
       
    98 	{
       
    99 	Cancel();
       
   100 	iFs.Close();
       
   101 	}
       
   102 
       
   103 /**
       
   104 Initialises the BIC's active object and initiates the command
       
   105 
       
   106 @param aStatus 	the TRequestStatus of the active object calling this BIC
       
   107 */	
       
   108 void CCmdFinaliseDrives::Execute( TRequestStatus& aStatus )
       
   109 	{
       
   110 	aStatus = KRequestPending;
       
   111 	iExecuteRequest = &aStatus;
       
   112 
       
   113 	CompleteRequest(iStatus, iFs.Connect());
       
   114 	SetActive();
       
   115 	}
       
   116 
       
   117 /**
       
   118 Releases resources associated with this BIC
       
   119 */	
       
   120 void CCmdFinaliseDrives::Release()
       
   121 	{
       
   122 	delete this;
       
   123 	}
       
   124 
       
   125 /**
       
   126 Initiates a Cancel on the object. 
       
   127 */	
       
   128 void CCmdFinaliseDrives::ExecuteCancel()
       
   129 	{
       
   130 	//cancel the outstanding request
       
   131 	Cancel();
       
   132 	//and complete the request with KErrCancel
       
   133 	CompleteExecuteRequest(KErrCancel);
       
   134 	}
       
   135 
       
   136 /**
       
   137 Returns the Type of the BIC
       
   138  
       
   139 @return		The Type of the BIC
       
   140 */	
       
   141 TSsmCommandType CCmdFinaliseDrives::Type() const
       
   142 	{
       
   143 	return (ESsmCmdFinaliseDrives);
       
   144 	}
       
   145 
       
   146 /**
       
   147 Returns the Version of the BIC
       
   148  
       
   149 @return		The maximum supported version of the BIC
       
   150 */	
       
   151 TInt CCmdFinaliseDrives::MaxSupportedVersion()
       
   152 	{
       
   153 	return (static_cast<TInt>(ECmdFinaliseDrivesInitialVersion));
       
   154 	}
       
   155 
       
   156 /**
       
   157 Configures the BIC using data contained in a ReadStream
       
   158  
       
   159 @param aReadStream 	A read stream containing BIC data
       
   160 */
       
   161 void CCmdFinaliseDrives::InternalizeL(RReadStream& aReadStream)
       
   162 	{
       
   163 	iSeverity = static_cast<TCmdErrorSeverity>(aReadStream.ReadInt16L());
       
   164 	}
       
   165 
       
   166 /**
       
   167 Externalises the configuration of the BIC
       
   168  
       
   169 @param aWriteStream A write stream to write BIC data to
       
   170 */
       
   171 void CCmdFinaliseDrives::ExternalizeL(RWriteStream& aWriteStream) const
       
   172 	{
       
   173 	aWriteStream.WriteInt16L(iSeverity);
       
   174 	}
       
   175 
       
   176 /**
       
   177 Completes the tasks of the BIC
       
   178 */
       
   179 void CCmdFinaliseDrives::RunL()
       
   180 	{
       
   181 	TInt error = iStatus.Int();
       
   182 	// These ASSERT_DEBUG statements are useful when the command is executed with 
       
   183 	// ECmdIgnoreFailure Severity. Any error is supressed with a panic in DEBUG builds
       
   184 	__ASSERT_DEBUG((KErrNone == error), PanicNow(KPanicCmdFinaliseDrives, ECmdExecutionFailed));
       
   185 	
       
   186 	if (KErrNone == error)
       
   187 		{
       
   188 		error = iFs.FinaliseDrives();
       
   189 		__ASSERT_DEBUG((KErrNone == error), PanicNow(KPanicCmdFinaliseDrives, ECmdExecutionFailed));
       
   190 		}
       
   191 	
       
   192 	// If it fails in UREL builds, the error is just returned to CLE
       
   193 	CompleteExecuteRequest(error);
       
   194 	}
       
   195 
       
   196 /**
       
   197 Called to handle any cleanup if RunL leaves
       
   198  
       
   199 @param aError 	The error to finish with
       
   200 @return			KErrNone
       
   201 */
       
   202 TInt CCmdFinaliseDrives::RunError(TInt aError)
       
   203 	{
       
   204 	CompleteExecuteRequest(aError);
       
   205 	return KErrNone;
       
   206 	}
       
   207 
       
   208 /**
       
   209 Called during cancellation of the active BIC
       
   210 */
       
   211 void CCmdFinaliseDrives::DoCancel()
       
   212 	{
       
   213 	}
       
   214 
       
   215 /**
       
   216 Default constructor.
       
   217 */
       
   218 CCmdFinaliseDrives::CCmdFinaliseDrives()
       
   219 	{
       
   220 	}
       
   221 
       
   222 /**
       
   223 Overloaded constructor
       
   224 
       
   225 @param aSeverity 	The severity of the command
       
   226 */
       
   227 CCmdFinaliseDrives::CCmdFinaliseDrives(TCmdErrorSeverity aSeverity)
       
   228 	: CSsmCommandBase(aSeverity)
       
   229 	{
       
   230 	}
       
   231 
       
   232 /**
       
   233 Constructs the object through read stream.
       
   234 @param aReadStream A read stream containing BIC data
       
   235 */
       
   236 void CCmdFinaliseDrives::ConstructL(RReadStream& aReadStream)
       
   237 	{
       
   238 	InternalizeL(aReadStream);
       
   239 	}
       
   240 
       
   241 /**
       
   242 Constructs an object from resource file.
       
   243 
       
   244 @param aCommandParameters Object data from a resource file
       
   245 */
       
   246 void CCmdFinaliseDrives::ConstructL(TSsmCommandParameters& aCommandParameters)
       
   247 	{
       
   248 	RResourceReader& reader = aCommandParameters.MainReader();
       
   249 	const TSsmCommandType type = static_cast<TSsmCommandType>(reader.ReadInt16L());
       
   250 	SSMLOGLEAVEIFFALSE(type == Type(), KErrNotSupported);
       
   251 	const TInt version = reader.ReadInt16L();
       
   252 	SSMLOGLEAVEIFFALSE(__COMPARE_VERSION(version, CCmdFinaliseDrives::MaxSupportedVersion()), KErrNotSupported);
       
   253 	iSeverity = static_cast<TCmdErrorSeverity>(reader.ReadInt16L());
       
   254 	}