sysstatemgmt/systemstatemgr/ssm/inc/ssmswppolicysrv.h
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2008-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 SSMSWPPOLICYSRV_H
       
    17 #define SSMSWPPOLICYSRV_H
       
    18 
       
    19 #include <e32base.h>
       
    20 #include <s32mem.h>
       
    21 #include <ssm/ssmswp.h>
       
    22 #include <ssm/ssmswppolicy.h>
       
    23 
       
    24 _LIT(KSsmSwpPolicySrvName, "!SsmSwpPolicySrv");
       
    25 
       
    26 class CSsmSwpPolicyStepCompletion;
       
    27 
       
    28 /**
       
    29  The SsmSwpPolicy server
       
    30  
       
    31 @internalComponent
       
    32 @released
       
    33 */
       
    34 NONSHARABLE_CLASS(CSsmSwpPolicyServer) : public CPolicyServer
       
    35 	{
       
    36 public:
       
    37 	static CSsmSwpPolicyServer* NewLC(const TDesC& aServerName);
       
    38 	IMPORT_C static TInt StartSsmSwpPolicySrv(const TDesC& aServerName);
       
    39 	~CSsmSwpPolicyServer();
       
    40 	
       
    41 	void RegisterSessionL( TInt& aSessionIndex);
       
    42 	void DeregisterSession( const TInt& aSessionIndex );
       
    43 	
       
    44 	void CallSetDllHandleAndInitializeL(const RMessage2& aMessage, TInt aSessionIndex);
       
    45 	void CallInitializeCancel(TInt aSessionIndex);
       
    46 	void CallPrepareCommandListL(const RMessage2& aMessage, TInt aSessionIndex);
       
    47 	void CallPrepareCommandListCancel(TInt aSessionIndex);
       
    48 	void CallCommandListL(const RMessage2& aMessage, TInt aSessionIndex);
       
    49 	void CallHandleCleReturnValueL(const RMessage2& aMessage, TInt aSessionIndex );
       
    50 	void CallHandleCleReturnValueCancel(TInt aSessionIndex );
       
    51 	
       
    52 	// From CServer2
       
    53 	IMPORT_C CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;
       
    54 
       
    55 	void DeleteSSwpPolicySessionInfo(TInt aSessionIndex);
       
    56 
       
    57 // This active object is used to call different steps involved in swp transition (viz Initialize/Prepare.. command list)
       
    58 // Since this server is used by CSsmSwpPolicyFrame, all the relevent checking like whether initalize is called before
       
    59 // prepare command list/ preparecommandlist is called before CallCommandList is checked, so no additional
       
    60 // checking is done while calling the swppolicy methods in this class
       
    61 NONSHARABLE_CLASS(CSsmSwpPolicyStepCompletion) : public CActive
       
    62 	{
       
    63 public:
       
    64 	enum TStep
       
    65 		{
       
    66 		EIdle = 0,
       
    67 		EInitialize,
       
    68 		EPrepareCommandList,
       
    69 		ECallCommandList,
       
    70 		EHandleCleReturnValue,
       
    71 		};
       
    72 public:
       
    73 	static CSsmSwpPolicyStepCompletion* NewL(MSsmSwpPolicy* aSwpPolicy, CSsmSwpPolicyServer& aServer, const TInt aSessionIndex);
       
    74 	~CSsmSwpPolicyStepCompletion();
       
    75 	
       
    76 	void StartInitialize(const RMessagePtr2& aMessagePtr2);
       
    77 	void StartPrepareCommandList(const TSsmSwp& aSwp, const RMessagePtr2& aMessagePtr2);
       
    78 	void StartHandleCleReturnValue(const TSsmSwp& aSwp, TInt aError, TInt aSeverity, const RMessagePtr2& aMessagePtr2);
       
    79 	
       
    80 	TStep CurrentStep() const;
       
    81 	void SetCurrentStep(TStep aStep);
       
    82 	
       
    83 protected:
       
    84 	void RunL();
       
    85 	void DoCancel();
       
    86 	TInt RunError();
       
    87 
       
    88 private:
       
    89 	CSsmSwpPolicyStepCompletion(MSsmSwpPolicy* aSwpPolicy, CSsmSwpPolicyServer& aServer, const TInt aSessionIndex);
       
    90 private:
       
    91 	TStep iStep;
       
    92 	RMessagePtr2 iMessagePtr;	// doesn't own
       
    93 	MSsmSwpPolicy* iSwpPolicy;	// doesn't own
       
    94 	TInt iSessionIndex;		// doesn't own, storing it to delete the session info once the swp request is completed
       
    95 	CSsmSwpPolicyServer& iServer;	// doesn't own
       
    96 	};	//CSsmSwpPolicyStepCompletion
       
    97 
       
    98 struct SSwpPolicySessionInfo
       
    99 	{
       
   100 	TBool iInUse;
       
   101 	MSsmSwpPolicy* iSwpPolicy;
       
   102 	CSsmSwpPolicyStepCompletion* iSsmSwpPolicyStepCompletion;
       
   103 	};	// SSwpPolicySessionInfo
       
   104 
       
   105 private:	
       
   106 	void ConstructL(const TDesC& aServerName);
       
   107 	CSsmSwpPolicyServer();
       
   108 	static TInt SsmSwpPolicySrvThreadFn(TAny* aAny);
       
   109 
       
   110 private:
       
   111 	RArray<SSwpPolicySessionInfo> iSessionInfoArray;
       
   112 	};
       
   113 
       
   114 inline CSsmSwpPolicyServer::CSsmSwpPolicyStepCompletion::TStep CSsmSwpPolicyServer::CSsmSwpPolicyStepCompletion::CurrentStep() const
       
   115 	{
       
   116 	return iStep;
       
   117 	}
       
   118 
       
   119 inline void CSsmSwpPolicyServer::CSsmSwpPolicyStepCompletion::SetCurrentStep(CSsmSwpPolicyServer::CSsmSwpPolicyStepCompletion::TStep aStep)
       
   120 	{
       
   121 	iStep = aStep;
       
   122 	}
       
   123 
       
   124 #endif //SSMSWPPOLICYSRV_H