sysstatemgmt/systemstatemgr/cmd/inc/cmdmultiplewait.h
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 #ifndef __CMDMULTIPLEWAIT_H__
       
    17 #define __CMDMULTIPLEWAIT_H__
       
    18 
       
    19 #include "ssmcommandbase.h"
       
    20 
       
    21 class RReadStream;
       
    22 class TSsmCommandParameters;
       
    23 
       
    24 /**
       
    25 A command object responsible for checking that all deferred commands in the list preceding 
       
    26 this multiple wait command have finished.  
       
    27 Commandlist must be externalized and internalized in order to populate the deferred list 
       
    28 of MULTIPLE_WAIT command.
       
    29 
       
    30 @internalComponent
       
    31 @released
       
    32 */
       
    33 NONSHARABLE_CLASS(CCmdMultipleWait) : public CSsmCommandBase
       
    34 	{
       
    35 public:
       
    36 	static CCmdMultipleWait* NewL(RReadStream& aReadStream, TArray<MSsmCommand*>& aDeferredCommands);
       
    37 	static CCmdMultipleWait* NewL(TInt32 aTimeout);
       
    38 	static CCmdMultipleWait* NewL(TSsmCommandParameters& aCommandParameters);
       
    39 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE
       
    40 	static CCmdMultipleWait* NewL(TInt32 aTimeout,const TUint16 aPriority);
       
    41 #endif
       
    42 	//Must be used only by CLE to reconstruct the command
       
    43 	static CCmdMultipleWait* NewLC(const CCmdMultipleWait& aCmdMultipleWait, TArray<MSsmCommand*>& aDeferredCommands);
       
    44 	~CCmdMultipleWait();
       
    45 
       
    46 	// from MSsmCommand
       
    47 	void Execute(TRequestStatus& aStatus);
       
    48 	void Release();
       
    49 	void ExecuteCancel();
       
    50 	TSsmCommandType Type() const;
       
    51 	void ExternalizeL(RWriteStream& aWriteStream) const;
       
    52 
       
    53 	void HandleTimeoutCallback();
       
    54 	inline TInt32 Timeout() const {return iTimeout;}
       
    55 
       
    56 private:
       
    57 	enum TStates
       
    58 		{
       
    59 		EStateCheckCompletionStatus = 0,
       
    60 		EStateTakeAction,
       
    61 		EStateTimerExpired
       
    62 		};
       
    63 
       
    64 	//CTOR's
       
    65 	CCmdMultipleWait();
       
    66 	CCmdMultipleWait(TInt32 aTimeout);
       
    67 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE
       
    68 	CCmdMultipleWait(TInt32 aTimeout, const TUint16 aPriority);
       
    69 #endif
       
    70 
       
    71 	//ConstructL's
       
    72 	void ConstructL(TArray<MSsmCommand*>&  aDeferredCommands, RReadStream& aReadStream);
       
    73 	void ConstructL(TSsmCommandParameters& aCommandParameters);
       
    74 	void ConstructL();
       
    75 	void ConstructL(const CCmdMultipleWait& aCmdMultipleWait, TArray<MSsmCommand*>& aDeferredCommands);
       
    76 	//helper functions
       
    77 	void CheckCompletion();
       
    78 	void TakeProperAction();
       
    79 	void MoveToNextState(TStates aNextState);
       
    80 	void InternalizeL(RReadStream& aReadStream);
       
    81 	void Cleanup();
       
    82 	static TInt MaxSupportedVersion();
       
    83 
       
    84 	//AO to handle multiple wait timeout
       
    85 	class CMultipleWaitTimer : public CTimer
       
    86 		{
       
    87 		public:
       
    88 			static CMultipleWaitTimer* NewL(CCmdMultipleWait& aMultipleWaitCmd);
       
    89 			~CMultipleWaitTimer();
       
    90 			void StartTimer(TInt32 aTimeout);
       
    91 
       
    92 		protected:
       
    93 			// from CActive
       
    94 			void RunL();
       
    95 
       
    96 		private:
       
    97 			void ConstructL();
       
    98 			CMultipleWaitTimer(CCmdMultipleWait& aMultipleWaitCmd);
       
    99 
       
   100 		private:
       
   101 			CCmdMultipleWait& iMultipleWaitCmd;
       
   102 		};
       
   103 
       
   104 protected:
       
   105 	// from CActive
       
   106 	void RunL();
       
   107 	void DoCancel();
       
   108 	TInt RunError(TInt aError);
       
   109 
       
   110 private:
       
   111 	RPointerArray<MSsmCommand> iDeferredCommands;
       
   112 	TInt32 iTimeout;
       
   113 	CMultipleWaitTimer* iMultipleWaitTimer;
       
   114 
       
   115 	// data members for maintaining internal state of multiple wait
       
   116 	// index of the current deferred command
       
   117 	TInt iCommandIndex;
       
   118 	// internal state maintained by MULTIPLE_WAIT command
       
   119 	TStates iInternalState;
       
   120 	TInt iCommandError;
       
   121 	};
       
   122 
       
   123 #endif // __CMDMULTIPLEWAIT_H__